How Can I Insert Radiobutton Value To SQLite (radio button 1 & radio button 2 has a value of 1)

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

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 image

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);
   }
 };

}