-3

I want to make a button with timer in Android, If a user click on this button then the button doesn't work before 30 minutes. The time will show the right of this button. Any body can help me with this?
Thank you

mr Mohi
  • 1
  • 1

1 Answers1

0

Try this code :

int minutes = 30;
int seconds = 60;

//here in id place your button id
Button button = (Button)findViewById(R.id.button_id)

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
    ((Button) findViewById(R.id.click)).setEnabled(false);

    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {

           \\ your button action here

        }
    },minutes*seconds*1000);

}
});
Sari Masri
  • 206
  • 1
  • 10
  • I showed you how to use the button with a delay but you should write your code in the run function, changing the text on the button with creating a new timmer try to use the code in this link [https://stackoverflow.com/questions/31639105/start-timer-on-button-click] – Sari Masri Nov 11 '18 at 14:57