The easiest way is to detect the "Fling" gesture. The Android API has a built-in detector for basic gestures such as toss, scroll, long press, double tap, zoom, etc.
The documentation is available at http://developer.android.com/reference/android/view/GestureDetector.html .
What you do is create an instance of GestureDetector, override the onTouchEvent method for the view that you are interested in detecting gestures, and pass the MotionEvent to the GestureDetector.
OnGestureListener ( SimpleOnGestureListener) GestureDetector .
:
class MyView extends View
{
GestureDetector mGestureDetect;
public MyView(Context context)
{
super(context);
mGestureDetect = new GestureDetector(new SimpleOnGestureListener()
{
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
if(e1.getX() - e2.getX() > 0)
{
}
if(velocityX > 50)
{
}
return true;
}
}
}
public boolean onTouchEvent(MotionEvent ev)
{
mGestureDetector.onTocuhEvent(ev);
return true;
}
}