vendredi 2 novembre 2018

i am trying to using putextra on my checkbox, but i can not go to the next activity, it is back to 1st activity

**i want to put my own score from first activity and im using a checkbox method. by selecting that checkbox, they have their own score which is one. after selecting that checkbox and press button next, it will go to the next activities which contain that score 1, then the process in this second activity do the same as 1st activity, but only different is the score must increase by 1. i will show my work on ist activity belowenter code here*

public class AfterNoYesQ1Activity extends AppCompatActivity {

Button buttonNext;

TextView textViewClickHere;




int score = 1;


CheckBox check1,check2,check3,check4,check5,check6,check7;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_after_no_yes_q1);

    check1 = (CheckBox)findViewById(R.id.checkBox1);
    check2 = (CheckBox)findViewById(R.id.checkBox2);
    check3 = (CheckBox)findViewById(R.id.checkBox3);
    check4 = (CheckBox)findViewById(R.id.checkBox4);
    check5 = (CheckBox)findViewById(R.id.checkBox5);
    check6 = (CheckBox)findViewById(R.id.checkBox6);
    check7 = (CheckBox)findViewById(R.id.checkBox7);


    buttonNext = (Button)findViewById(R.id.buttonNext);

    buttonNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {



            Intent intent = new Intent(AfterNoYesQ1Activity.this, DetectionQues2Activity.class);
            startActivity(intent);



        }
    });


    textViewClickHere = (TextView) findViewById(R.id.textViewClickHere);

    textViewClickHere.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(AfterNoYesQ1Activity.this, DetectionQues2Activity.class);
            startActivity(intent);




        }
    });


}

public void checkone (View view)

{

    if (check1.isChecked() && check5.isChecked() && check6.isChecked())
    {


        getIntent().putExtra("score",score);


    }
    else if (check1.isChecked() && check5.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check1.isChecked() && check6.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check2.isChecked() && check5.isChecked() && check6.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check2.isChecked() && check5.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check2.isChecked() && check6.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check3.isChecked() && check5.isChecked() && check6.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check3.isChecked() && check5.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check3.isChecked() && check6.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check3.isChecked() && check5.isChecked() && check6.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check3.isChecked() && check5.isChecked() && check7.isChecked())
    {
        //fail
        getIntent().putExtra("score",score);

    }
    else if (check1.isChecked() && check5.isChecked() && check6.isChecked())
    {

    }
    else if (check3.isChecked() && check6.isChecked() && check7.isChecked())
    {
        //fail

    }
    else if (check1.isChecked() && check2.isChecked() && check5.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check6.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check7.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked() && check5.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked() && check6.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked() && check7.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked()
            && check4.isChecked() && check5.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked()
            && check4.isChecked() && check6.isChecked())
    {
        //pass

    }
    else if (check1.isChecked() && check2.isChecked() && check3.isChecked()
            && check4.isChecked() && check7.isChecked())
    {
        //pass

    }



    score = score + 1;

}

}




Aucun commentaire:

Enregistrer un commentaire