im writing a quiz app on android studio, now, my goal is to add a time penalty for each wrong answer, means, if the user answered wrong he will have to wait lets say 10 sec' until he will be able to answer again, on those 10 sec', the app will freeze and the user will have to wait.
i want to show the time remaining.
the timer should be inserted in this part of the code:
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())) {//bad equal to
score++;
Log.d("good answer", "Your score" + score);
}else {
Log.d("bad answer", "Your score" + score);
***//the time should be implemented here***
}
if (qid < 7) {
currentQ = quesList.get(qid);
setQuestionView();
} else {
Intent intent = new Intent(Questionsctivity.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();
}
}
});
thanks