enable GestureDetector Flipper - Android android.view

Android examples for android.view:GestureDetector

Description

enable GestureDetector Flipper

Demo Code


//package com.java2s;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

public class Main {
    public static void enableFlipper(View view,
            GestureDetector.OnGestureListener listener) {
        final GestureDetector det = new GestureDetector(view.getContext(),
                listener);//from  w  w w.  ja va2 s. c om
        if (listener instanceof GestureDetector.OnDoubleTapListener) {
            det.setOnDoubleTapListener((GestureDetector.OnDoubleTapListener) listener);
        }
        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return det.onTouchEvent(event);
            }
        });
    }
}

Related Tutorials