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
Android Preventing Double Click On A Button
Disable the button with setEnabled(false)
until it is safe for the user to click it again.
Differentiate Single click and double click of a imageView in android
just a little change and my code works fine. I placed the mHasDoubleClicked boolean inside handler, that makes the trouble. The below code works.
img_feat_orgn_item.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
findDoubleClick();
if (mHasDoubleClicked) {
Log.v("double click","double click");
startActivity(new Intent(
Wv_HomePage.this,
NewDonation.class));
}
}
});
private boolean findDoubleClick() {
// Get current time in nano seconds.
long pressTime = System.currentTimeMillis();
// If double click...
if (pressTime - lastPressTime <= DOUBLE_PRESS_INTERVAL) {
mHasDoubleClicked = true;
// double click event....
} else { // If not double click....
mHasDoubleClicked = false;
Handler myHandler = new Handler() {
public void handleMessage(Message m) {
if (!mHasDoubleClicked) {
// single click event
feature_class_val = listData_Feature_Organization
.get(j);
Intent intent = new Intent(
Wv_HomePage.this,
OrganizationDetails.class);
Bundle b = new Bundle();
b.putString("orgn_name",
feature_class_val.name);
intent.putExtras(b);
startActivity(intent);
}
}
};
Message m = new Message();
myHandler.sendMessageDelayed(m, DOUBLE_PRESS_INTERVAL);
}
lastPressTime = pressTime;
return mHasDoubleClicked;
}
Single Click and Double Click in EditText using the click listener
Use GestureDetector
to detect:
final GestureDetector gestureDetector = new GestureDetector(your_context,new GestureDetector.SimpleOnGestureListener() {
public boolean onDoubleTap(MotionEvent e) {
// start activity
return true;
}
});
EditText et = (EditText) findViewById(R.id.your_id);
et.setOnTouchListener(new View.OnClickListener() {
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
});
Related Topics
Getlaunchintentforpackage Is Null for Some Apps
Android 'Debuggable' Default Value
Using Intent.Action_Pick for Specific Path
Android Facebook Authorization - Can Not Log in When Official Facebook App Is Installed
When Should One Use Rxjava Observable and When Simple Callback on Android
Decoding Raw H264 Stream in Android
Android Task Affinity Explanation
Cannot Find Zip-Align When Publishing App
Android Id Naming Convention: Lower Case with Underscore VS. Camel Case
Single Observable with Multiple Subscribers
Garbage Collection Causes:Mediaplayer Finalized Without Being Released
Cordova - Error: Failed to Fetch Platform Android
Out of Memory Exception Due to Large Bitmap Size
Checkbox Gets Unchecked on Scroll in a Custom Listview
How to Hide One Item in an Android Spinner
Resize Image to Full Width and Variable Height with Picasso
Java.Lang.Illegalstateexception: the Specified Child Already Has a Parent