Good day everyone, so i am writing a quiz app and score is based on what the user selects. I used radio buttons, check box and edit text tags for answering questions. When the user clicks a radio button, or a check box, the score updates, but when the user enters the correct text in the EditText field, the score does not update. I used an if else statement to check if the string entered matches an answer.
public void startFinalScreen(View v) {
EditText text = (EditText) findViewById(R.id.edit_text_view_answer);
int questionNineScore = getIntent().getIntExtra("GNS", 0);
int finalScore = questionNineScore;
String answer = "William Shakespeare";
if (text.getText().toString() == answer) {
qNineScore = qNineScore + 1;
}
finalScore = qNineScore;
}
I used .getIntent()
to get score from a previous activity. After i do this, the score does not add +1 even after typing the correct answer.