Radinator Radinator - 1 year ago 79
Android Question

Detection of swiping on a normal Android Activity

Is it possible, to detect a swiping to the left/right of the user in a normal Android activity? Or do I have to use a SwipeView?

Answer Source

According with https://developer.android.com/training/gestures/detector.html

You can implement GestureDetector.OnGestureListener in your activity class and override onFling or onScroll

public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
        float distanceY) {
    Log.d(DEBUG_TAG, "onScroll: " + e1.toString()+e2.toString());
    return true;

public boolean onFling(MotionEvent event1, MotionEvent event2,
        float velocityX, float velocityY) {
    Log.d(DEBUG_TAG, "onFling: " + event1.toString()+event2.toString());
    return true;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download