Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android prevent duplicate click
private long mLastClickTime = 0L;
findViewById(R.id.button)
.setOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
// mis-clicking prevention :: 1000 ms
if (SystemClock.elapsedRealtime() - mLastClickTime < 1000) return;
mLastClickTime = SystemClock.elapsedRealtime();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.