A
Android Question
Guest
butNext.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
RadioGroup grp = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton answer = (RadioButton) findViewById(grp.getCheckedRadioButtonId());
Log.d("yourans", currentQ.getANSWER() + " " + answer.getText());
if (currentQ.getANSWER().equals(answer.getText())) {
Toast.makeText(DeldActivity.this, "Awesome Right Answer.;-)", Toast.LENGTH_SHORT).show();
score++;
Log.d("score", "Your score" + score);
} else {
Toast.makeText(DeldActivity.this, "Wrong Answer.The Right Answer is " + currentQ.getANSWER(), Toast.LENGTH_SHORT).show();
}
if (qid < totalq) {
grp.clearCheck();
currentQ = quesList.get(qid);
setQuestionView();
} else {
Intent intent = new Intent(DeldActivity.this, DeldResultActivity.class);
Bundle b = new Bundle();
Bundle total = new Bundle();
b.putInt("score", score); //Your score
b.putInt("qid", qid);
intent.putExtras(b);
intent.putExtras(total);//Put your score to your next Intent
startActivity(intent);
finish();
}
}
});
}
when I click on the radio button with no button checked the app force stops please give me a solution
@override
public void onClick(View v) {
RadioGroup grp = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton answer = (RadioButton) findViewById(grp.getCheckedRadioButtonId());
Log.d("yourans", currentQ.getANSWER() + " " + answer.getText());
if (currentQ.getANSWER().equals(answer.getText())) {
Toast.makeText(DeldActivity.this, "Awesome Right Answer.;-)", Toast.LENGTH_SHORT).show();
score++;
Log.d("score", "Your score" + score);
} else {
Toast.makeText(DeldActivity.this, "Wrong Answer.The Right Answer is " + currentQ.getANSWER(), Toast.LENGTH_SHORT).show();
}
if (qid < totalq) {
grp.clearCheck();
currentQ = quesList.get(qid);
setQuestionView();
} else {
Intent intent = new Intent(DeldActivity.this, DeldResultActivity.class);
Bundle b = new Bundle();
Bundle total = new Bundle();
b.putInt("score", score); //Your score
b.putInt("qid", qid);
intent.putExtras(b);
intent.putExtras(total);//Put your score to your next Intent
startActivity(intent);
finish();
}
}
});
}
when I click on the radio button with no button checked the app force stops please give me a solution
.