- Forum posts: 1
Jan 12, 2016, 4:26:02 PM via Website
Jan 12, 2016 4:26:02 PM via Website
I Am Creating A Voting App For Our School And I Need A To Create A Database To Store The Votes. This Is The Result Activity
This Is The Result.java
package com.unicorninteractive.ssgelectionmobilerssths;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.TextView;
public class results extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_results);
}
}
And This Is The President.java (Voting Activity)
package com.unicorninteractive.ssgelectionmobilerssths;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;
public class President extends AppCompatActivity {
Button btn_votep;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_president);
btn_votep = (Button) findViewById(R.id.btn_votep);
btn_votep.setOnClickListener(btnlistener);
Toast toast=Toast.makeText(this, "Your Vote Is Now Counted", Toast.LENGTH_LONG);
toast.show();
}
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.rb_p1:
if (checked)
// President 1
break;
case R.id.rb_p2:
if (checked)
// President 2
break;
}
}
private View.OnClickListener btnlistener = new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(President.this , Vicepresident.class);
startActivity(intent);
}
};
}
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.