I develop a quiz application in Android. I want to show all question on single activity. When user selected a choice, if it is correct, set color is green, if it is false, set color red. And get new question and choices. I wrote code on onClick event:
public void onClickChoice(View v) {
String text = ((TextView) v).getText().toString();
if (text == currentAnswer) {
v.setBackgroundColor(getResources().getColor(newGreen));
} else {
v.setBackgroundColor(getResources().getColor(newRed));
}
setNewQuestion();
}
When run application, I answered first question and second question is came, and color of second question's choice is changed. What should I do for solving this problem.