How do not have a miss click on the next screen?

Asked

Viewed 47 times

0

I’m having a little problem with a quiz application. when the user clicks on the button the next question comes. put a delay of 1 sec. However, if the user clicks 2x on the button within this delay of 1 sec, when opening the next question it will already be clicked.

     private void ResetTempo() {
     mCountDownTimer.cancel();
     mTimeLeft = StartTempo;
     try {
        new Thread().sleep(1000);
     } catch (InterruptedException e) {
        e.printStackTrace();
     }
     mCountDownTimer.start();
     }

           r4.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            r4.setEnabled(false);
            ResetTempo();         

            updatePerguntasoma(r.nextInt(mPerguntasomaLenght));
                    r4.setEnabled(true);
  • Can you be more specific or show some example?

  • I have a quiz with one question and four answers, four buttons. If the user gives 2 clicks on the first answer... the first and second question are answered by the button. I showed you the code, 'cause I want a 1 sec Sleep.. Then the user of 2 clicks, the question waits 1 sec and is answer, opens the second question and is answered (after 1 sec too) also by double clicking on the first question. I can’t explain it any more clearly.

1 answer

0

I believe that if you disable the button while in delay already solve.

myButton.setEnabled(false); 
  • Good! I thought it was a good idea! It works, but the button is inactive! I made the button true again after the delay! but if I double click! the button is triggered, disabled, waited 1 second, goes to the next question, the button is enabled again, and(that click is "waiting" the button enable, and automatically the second question is already answered by the same button)

  • Then put a condition inside the click event to go to the next question only if the user answers the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.