使用本地Sqlite数据库开发简单的测验应用程序,但得分不高

时间:2016-04-20 17:27:05

标签: java android sql

我正在使用本地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 :路由器04-20 17:32:53.218 19972-19972 / com.example.zeenat.quizappsqlite D / yourans:C Ruby

1 个答案:

答案 0 :(得分:1)

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