0

My users to be able to click a button and go to a game. Once the game is finished the game goes back to the menu, where the button was initially clicked. I want this button to disappear or be disabled for a certain amount of time (Say 30 seconds?) before being able to be clicked again. The users should be able to see a timer count down from 30 seconds and then the button would reappear/be able to be clicked again.

How could I do this?

Sean O
  • 238
  • 3
  • 14

1 Answers1

1

You can use countdown timer , please check below code

new CountDownTimer(30000, 1000) {

            public void onTick(long millisUntilFinished) {
                button.setEnabled(false);
                button.setText("seconds remaining: " + millisUntilFinished / 1000);
            }

            public void onFinish() {
                button.setEnabled(true);
            }
        }.start();
Emad Seliem
  • 608
  • 1
  • 4
  • 5