How to implement double tap for surface view in android
You could try following.. actually i tested this and it works pretty well:
1) Extend GestureDetector.SimpleOnGestureListener
and override it's onDoubleTap()
method:
class DoubleTapGestureDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDoubleTap(MotionEvent e) {
Log.d("TAG", "Double Tap Detected ...");
return true;
}
}
2) Instantiate the GestureDetector
:
final GestureDetector mGesDetect = new GestureDetector(this, new DoubleTapGestureDetector());
3) Set an OnTouchListener
on your SurfaceView
, override its onTouch()
method and call the onTouchEvent()
on your GestureDetector
object:
surfview.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mGesDetect.onTouchEvent(event);
return true;
}
});