I am developing a small quiz app. The correct answers are stored in a string-array, so when the user select one of the options (radioButton for each option), I make a string comparisson.
If the answer was wrong, there should be a iteration on the other radioButtons to verify which has the same string as my answer array, to mark that was the right answer.
correctAnswer = answers[position];
int currentAnswerId = optionsRadioGroup.getCheckedRadioButtonId();
RadioButton selectedAnswer = (RadioButton) findViewById(currentAnswerId);
if(selectedAnswer.getText().equals(correctAnswer)) {
selectedAnswer.setTextColor(Color.GREEN);
}
else {
selectedAnswer.setTextColor(Color.RED);
//search the other radioButtons for the matching string
}
Any help would be appreciated, guess this one is not hard but I'm new to Android and Java Dev.