How to detect the double tap in android? I implement OnDoubleTapListener and wrote this:
public boolean onDoubleTapEvent(MotionEvent e) {
// TODO Auto-generated method stub
if(e.getAction() == 1){
Toast.makeText(getApplicationContext(),"Double Tap", Toast.LENGTH_SHORT).show();
}
return true;
}
But it is not working. What is the wrong with this?
public class GestureDoubleTap extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDoubleTap(MotionEvent e) {
//some logic
return true;
}
}
GestureDoubleTap gestureDoubleTap = new GestureDoubleTap();
gestureDetector = new GestureDetector(this/* context */, gestureDoubleTap);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return gestureDetector.onTouchEvent(motionEvent);
}
});