Implement double click for button in Android
This is a good site for performing double click...
I used it and worked.
http://mobile.tutsplus.com/tutorials/android/android-gesture/
How to detect double click event for buttons in android
There is an excellent answer here:
Single click and double click of a button in android
However, I suggest using the OnLongPress event, which is what comes recommended from Google.
View that API here:
http://developer.android.com/reference/android/view/View.OnLongClickListener.html
Cheers
how to implement double click in android
Why dont you use Long Press event insted while its Recommanded UI. Read Answer Here , I strongly recommand to use this.
Or if its anyhow you want to implement you have two options , one is this using boolean
and second is using Gesture Listener.
Android Preventing Double Click On A Button
Disable the button with setEnabled(false)
until it is safe for the user to click it again.
Android Studio - How to perform doubleClick in Kotlin?
I implemented this library using Kotlin, you can just define the doubleClick property and override single and double click methods, and finally add it to setOnClickListener of your button
val doubleClick = DoubleClick(object : DoubleClickListener {
override fun onSingleClickEvent(view: View?) {
// DO STUFF SINGLE CLICK
}
override fun onDoubleClickEvent(view: View?) {
// DO STUFF DOUBLE CLICK
}
})
button.setOnClickListener(doubleClick)
https://gitlab.com/developerdeveloperdeveloper/androidutilslibrary
How to handle double click on event onclicklistener in android studio?
Please try below:-
Java Version:-
private var doubleClickLastTime = 0L
view.setOnClickListener {
if(System.currentTimeMillis() - doubleClickLastTime < 300){
doubleClickLastTime = 0
doAction()
}else{
doubleClickLastTime = System.currentTimeMillis()
}
}
Kotlin Version:-
val doubleClickLastTime = 0L
view.setOnClickListener
run({ if (System.currentTimeMillis() - doubleClickLastTime < 300)
{
doubleClickLastTime = 0
doAction()
}
else
{
doubleClickLastTime = System.currentTimeMillis()
} })
How to prevent rapid double click on a button
I am doing like this it works very well.
public abstract class OnOneOffClickListener implements View.OnClickListener {
private static final long MIN_CLICK_INTERVAL=600;
private long mLastClickTime;
public static boolean isViewClicked = false;
public abstract void onSingleClick(View v);
@Override
public final void onClick(View v) {
long currentClickTime=SystemClock.uptimeMillis();
long elapsedTime=currentClickTime-mLastClickTime;
mLastClickTime=currentClickTime;
if(elapsedTime<=MIN_CLICK_INTERVAL)
return;
if(!isViewClicked){
isViewClicked = true;
startTimer();
} else {
return;
}
onSingleClick(v);
}
/**
* This method delays simultaneous touch events of multiple views.
*/
private void startTimer() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
isViewClicked = false;
}
}, 600);
}
}
Related Topics
Android:How to Upload .Mp3 File to Http Server
How to Display Both Icon and Title of Action Inside Actionbar
Android Studio Image Asset Launcher Icon Background Color
Android Opening a File with Action_Get_Content Results into Different Uri'S
How to Add "Android Design Support Library" to Eclipse with Adt-Plugin
Android Marshmallow: Test Permissions with Espresso
Slidedown and Slideup Layout with Animation
Google Play Services Out of Date. Requires 11011000 But Found 10289574
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed
Finding the Dominant Color of an Image in an Android @Drawable
Error in Strings.Xml File in Android
Android Downloadmanager Progress