Code example for GestureDetector

0
    private Listener mListener;
 
    public PanelSwitcher(Context context, AttributeSet attrs) {
        super(context, attrs);
        mCurrentView = 0;
        mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
                @Override 
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                                       float velocityY) {
                    int dx = (int) (e2.getX() - e1.getX());
 
                    // don't accept the fling if it's too short 
                    // as it may conflict with a button push 
                    if (Math.abs(dx) > MAJOR_MOVE && Math.abs(velocityX) > Math.abs(velocityY)) {
                        if (velocityX > 0) {
                            moveRight(); 
                        } else { 
                            moveLeft(); 
                        } 
                        return true; 
Connect your IDE to all the code out there  Get Codota for Java