Handle Touch Event On Both Segments Of The Screen Simultaneously
So I have a touch event and it handles ACTION_DOWN and ACTION_UP one by one. For example if I click on the left half of the screen ACTION_DOWN works but not ACTION_UP and same for
Solution 1:
here is the docs to handle multi touch gestures.
https://developer.android.com/training/gestures/multi#java
Here is a very simple example to handle multitouch based on google docs.
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getActionMasked();
int index = event.getActionIndex();
System.out.println("The finger # " + index + " is " + getAction(action));
returntrue;
}
publicstatic String getAction(int action) {
switch (action) {
case MotionEvent.ACTION_DOWN: return"Down";
case MotionEvent.ACTION_MOVE: return"Move";
case MotionEvent.ACTION_POINTER_DOWN: return"Pointer Down";
case MotionEvent.ACTION_UP: return"Up";
case MotionEvent.ACTION_POINTER_UP: return"Pointer Up";
case MotionEvent.ACTION_OUTSIDE: return"Outside";
case MotionEvent.ACTION_CANCEL: return"Cancel";
default: return"Unknown";
}
}
Post a Comment for "Handle Touch Event On Both Segments Of The Screen Simultaneously"