我正在使用本地SQlite数据库获取数据。它会正确显示在视图中,但分数不会增加。你看到问题了吗?

RadioGroup grp = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton answer = (RadioButton) findViewById(grp.getCheckedRadioButtonId());
Log.d("yourans", currentQ.getANSWER()+" "+answer.getText());
//problem is here score not incress ...
if (currentQ.getANSWER().equals(answer.getText())) {
         score++;
         Log.d("score", "Your score" + score);
}
if(qid<5){
     currentQ=quesList.get(qid);
     setQuestionView();
}else{
     Intent intent = new Intent(MainActivity.this, ResultActivity.class);
     Bundle b = new Bundle();
     b.putInt("score", score); //Your score
     intent.putExtras(b); //Put your score to your next Intent
     startActivity(intent);
     finish();
}


这是日志输出:

04-20 17:32:50.448 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:C HP 04-20 17:32:51.648 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:B SuSe 04-20 17:32:52.178 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:C RAM 04-20 17:32:52.688 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:A Router 04-20 17:32:53.218 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:C Ruby

最佳答案

您正在检查给定答案(字母A,B,C)是否等于正确答案文本。您提高分数的代码将永远不会被调用。 answer.getText()不返回单个字母,它将为您提供答案文本。 currentQ.getANSWER()只会给您用户选择的单个字母。

10-08 15:28