Answer the question
In order to leave comments, you need to log in
How to temporarily block a button in Android Studio?
After pressing, it is necessary to block the button for a few seconds, and then make it active again. Preferably with sample code.
Answer the question
In order to leave comments, you need to log in
Thread.sleep is not an option.
Try using Handler with a delayed call, handler.postDelayed
Button button = (Button) findViewById(R.id.Button);
button.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View v) {
button.setEnabled(false);
Thread.sleep(5000); // пауза на 5 секунд
button.setEnabled(true);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question