dimanche 10 janvier 2016

Insert Radiobutton Value To SQLite

I Am Creating A Voting App For Our School And I Need A To Create A Database To Store The Votes. This Is The video 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);
       }
     };
   }

Aucun commentaire:

Enregistrer un commentaire