Reputation: 621
How can i get X and Y position of touches of double tap events, maybe like a game where you select the initial position and final position so i get oldX,oldY
and newX,newY
I have tried an if...else
statement with a boolean
firsttouch
initially to true
and modifying this boolean in both if
and else
since i only want to get two touches.
Note: I am not talking about dragging;
Upvotes: 0
Views: 142
Reputation: 23638
You need to implement the Double Tap event using GestureDetector
as below:
GestureDetector gd = new GestureDetector(this); gd.setOnDoubleTapListener(new OnDoubleTapListener() { public boolean onSingleTapConfirmed(MotionEvent e) { Toast.makeText(getApplicationContext(),"Single Tap Called", Toast.LENGTH_SHORT).show(); return false; } public boolean onDoubleTapEvent(MotionEvent e) { return false; } public boolean onDoubleTap(MotionEvent e) { Toast.makeText(getApplicationContext(), "Double Tap Called", Toast.LENGTH_SHORT).show(); } });
Upvotes: 1