I have a problem with if statement. Two values - strings, one declared in class by arrow and another declared by radiobutton.gettext(). In debuging i can read values of both var. and they are same, but if statement says they are different. Do you have any idea why is this happening?
Debuger: https://i.stack.imgur.com/jYrMV.jpg
Getting rbAnswer :
private String mChoices [][] = {
/* #8 */ {"razgovor između pomoraca u karanteni i njihovih obitelji", "za osobno razmatranje i razgovor s duhovnikom"," "," "},
}
...
public String getChoice1(int a) {
String choice0 = mChoices[a][0];
return choice0;
}
public String getChoice2(int a) {
String choice1 = mChoices[a][1];
return choice1;
}
...
rbGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
String rbAnswer;
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.radiobtn1)
rbAnswer = "" + rb1.getText();
else if (checkedId == R.id.radiobtn2)
rbAnswer = "" + rb2.getText();
else if (checkedId == R.id.radiobtn3)
rbAnswer = "" + rb3.getText();
else if (checkedId == R.id.radiobtn4)
rbAnswer = "" + rb4.getText();
tTEST.setText(rbAnswer);
if (rbAnswer == mAnswer) {
varScoreTrue = varScoreTrue + 1;
updateScore(varScoreTrue);
obavijestTocno();
updateQuestion();
} else {
varScoreFlase = varScoreFlase + 1;
updateScore(varScoreFlase);
obavijestKrivo();
updateQuestion();
}
}
});
Declaring mAnswer:
private String mCorrectAnswers[] = {
...
/* #8 */ "za osobno razmatranje i razgovor s duhovnikom",
...
}
...
public String getCorrectAnswer(int a) {
String answer = mCorrectAnswers[a];
return answer;
}
...
mAnswer = mQuestionLibrary.getCorrectAnswer(mQuestionNumber);