I have 5 radio groups with 4 radio buttons each. Every radio button represents an answer to a question. I want when someone press the button, if the correct answer is checked, to set the color of the that text in green. With this code, when i press the button, nothing happens. Any ideas? Here is my code:
boolean isChecked;
int CorrectAnswer;
RadioButton checkedRadioButton;
answer[j].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RadioButton checkedRadioButton = ((RadioButton) v);
int CorrectAnswer = Integer.parseInt(checkedRadioButton.getTag().toString());
isChecked = true;
if (isChecked) {
if (checkedRadioButton.isChecked() & CorrectAnswer == 1) {
score++;
isChecked = false;
}
}
}
finishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 0; i < radioGroup.length; i++) {
for (int j = 0; j < answer.length; j++) {
radioGroup[i].getChildAt(j).setEnabled(false);
if (CorrectAnswer == 1) {
checkedRadioButton.setTextColor(Color.GREEN);
}
}
}
}
});
Thanks!
Aucun commentaire:
Enregistrer un commentaire