Skip to content

Instantly share code, notes, and snippets.

@hwshim0810
Created June 26, 2018 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwshim0810/f5b5120a1cc1881bb429a4226d701993 to your computer and use it in GitHub Desktop.
Save hwshim0810/f5b5120a1cc1881bb429a4226d701993 to your computer and use it in GitHub Desktop.
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