I have looked at the answers here - Android Preventing Double Click On A Button
and implemented qezt\'s solution like and I\'ve tried setEnabled(false) like so
public static void disablefor1sec(final View v) {
try {
v.setEnabled(false);
v.setAlpha((float) 0.5);
v.postDelayed(new Runnable() {
@Override
public void run() {
try {
v.setEnabled(true);
v.setAlpha((float) 1.0);
} catch (Exception e) {
Log.d("disablefor1sec", " Exception while un hiding the view : " + e.getMessage());
}
}
}, 1000);
} catch (Exception e) {
Log.d("disablefor1sec", " Exception while hiding the view : " + e.getMessage());
}
}
I kept above method in a static file and i will call this method for all the buttonclick like this
button_or_textview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StaticFile.disablefor1sec(button_or_textview);
// Do Somthing.
}
});