Code example for GestureDetector

Methods: setIsLongpressEnabled

0
     * Constructor 
     * @param context the current context 
     * @param listener the scrolling listener 
     */ 
    public WheelScroller(Context context, ScrollingListener listener) {
        gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
            public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                // Do scrolling in onTouchEvent() since onScroll() are not call immediately 
                //  when user touch and move the spinnerwheel 
                return true; 
            } 
 
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                lastScrollPosition = 0;
                scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
                setNextMessage(MESSAGE_SCROLL);
                return true; 
            } 
 
            // public boolean onDown(MotionEvent motionEvent); 
 
        }); 
        gestureDetector.setIsLongpressEnabled(false);
         
        scroller = new Scroller(context);
 
        this.listener = listener;
        this.context = context;