I have a button and when it is pressed it plays an audio file. I want to put a 5 second delay on the button so users wont mash the button and play the sound over and over. I
Here you go.
((Button) findViewById(R.id.click))
.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() {
((Button) findViewById(R.id.click))
.setEnabled(true);
}
}, 5000);
}
});