I am creating a quiz. I have 3 buttons (options) in action and their corresponding questions. Now, my problem is that I want to show the toast message when the user selects the correct answer, the toast message will appear in a few seconds, but when the user selects the wrong answer, it will display the toast message again. I do not know how to do that.
I have researched and read a lot of forums, but it seems that I do not understand and do not satisfy my needs. Can someone help? thanks in advance!
Bye, here is the code. But that does not work. Please correct me which code is wrong. Many thanks.
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Button btn1 = (Button) findViewById(R.id.btnopt1_a);
btn1.isClickable();
switch(arg0.getId()){
case R.id.btnopt1_a:
if(btn1.isPressed()){
Toast.makeText(getBaseContext(), "Your answer is correct!" , Toast.LENGTH_SHORT ).show();
}
else btn1.setText("Your answer is wrong!, The correct answer is: Frog");
break;
}
}
});
source
share