im having an application which needs onTouch swipe events like in Iphone. they are
- Swipe Up.
- Swipe Down.
- Swipe Left.
- Swipe Right.
i implemented onTouch event as following . and i got Swipe Left and Right actions correctly.but which is the correct way to implement the swipe Down and Up actions.
MYCODE:
float downXValue,downYValue; @Override public boolean onTouchEvent(MotionEvent arg1) { // Get the action that was done on this touch event switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: { // store the X value when the user's finger was pressed down downXValue = arg1.getX(); downYValue = arg1.getY(); break; } case MotionEvent.ACTION_UP: { // Get the X value when the user released his/her finger float currentX = arg1.getX(); float currentY=arg1.getY(); // going backwards: pushing stuff to the right if (downXValue < currentX) { Log.d(DEBUG_TAG, "Right"); } // going forwards: pushing stuff to the left if (downXValue > currentX) { Log.d(DEBUG_TAG, "Left"); } break; } } //GestureListener is called here... //return gestures.onTouchEvent(event); return true; } Thank you.