lundi 23 octobre 2017

How to check if only two checkboxes are checked?

I'm building a quiz app for practice and i wish to check if two checkboxes are checked(and add 1 to a variable if they are checked). Here is my code:

CheckBox questionFiveAnswer_1 = (CheckBox)findViewById(R.id.question5B);
boolean correctAnswer_5_1 = questionFiveAnswer_1.isChecked();

CheckBox questionFiveAnswer_2 = (CheckBox) findViewById(R.id.question5D);
boolean correctAnswer_5_2 = questionFiveAnswer_2.isChecked();

I don't want to link the remaining checkboxes to the MainActivity.Java file. Is there anyway i can check without accessing the remaining checkboxes? Thanks!




Aucun commentaire:

Enregistrer un commentaire