我正在制作一个测验应用程序,在执行此操作时,我的分数不会增加
即使答案是正确的。当我比较currentQ.getANSWER().equals(answer.getText())
并且此时score ++
之后,得分不会增加。以下是我的代码:
butNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RadioGroup grp=(RadioGroup)findViewById(R.id.radioGroup1);
answer=(RadioButton)findViewById(grp.getCheckedRadioButtonId());
if(currentQ.getANSWER().equals(answer.getText()))
{
score ++ ;
Log.d("tag"," " +score);
}
if(qid < 5) {
currentQ = quesList.get(qid);
}
setQuestionView();
}
});
在下一个按钮点击中,我想保存先前的响应并增加分数,但这不会发生。
DBhelper
private void addQuestions()
{
Question q1=new Question("Which company is the largest manufacturer" +
" of network equipment?","HP", "IBM", "CISCO", "C");
this.addQuestion(q1);
Question q2=new Question("Which of the following is NOT " +
"an operating system?", "SuSe", "BIOS", "DOS", "B");
this.addQuestion(q2);
Question q3=new Question("Which of the following is the fastest" +
" writable memory?","RAM", "FLASH","Register","C");
this.addQuestion(q3);
Question q4=new Question("Which of the following device" +
" regulates internet traffic?", "Router", "Bridge", "Hub","A");
this.addQuestion(q4);
Question q5=new Question("Which of the following is NOT an" +
" interpreted language?","Ruby","Python","BASIC","C");
this.addQuestion(q5);
}
这是我的dbhelper,我在其中添加了所有问题和答案。 我该怎么办?欢迎提出任何建议。