简单的双击和长按处理

2015-10-28

简单的双击和长按处理

1
GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            //处理你的双击事件

            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
        	 //处理你的长按事件
        }
    };
    
GestureDetector mGestureDetector = new GestureDetector(listener);
    
view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return mGestureDetector.onTouchEvent(motionEvent);
            }
        });