• 单手指和双手指(手势探测器)


    单手指:

    •   如果想要监听单手指操作的全部操作监听(有两个接口,仅需要挑选自己需要的来实现):

      

    public class SingleGesture implements GestureDetector.OnGestureListener,GestureDetector.OnDoubleTapListener {
    
        @Override
        public boolean onDown(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public void onShowPress(MotionEvent e) {
            // TODO Auto-generated method stub
            
        }
    
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
                float distanceY) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public void onLongPress(MotionEvent e) {
            // TODO Auto-generated method stub
            
        }
    
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                float velocityY) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
    }
    View Code
    •   如果仅仅想要监听单手指操作的一部分简单操作的监听:
    public class SingleGesture extends GestureDetector.SimpleOnGestureListener {
    
    }

      因为SimpleOnGestureListener实现了onGestureListener接口和onDoubleTapListener接口,所以仅仅需要重写两个接口上的所需要的方法即可

        

     
    /**
         * A convenience class to extend when you only want to listen for a subset
         * of all the gestures. This implements all methods in the
         * {@link OnGestureListener} and {@link OnDoubleTapListener} but does
         * nothing and return {@code false} for all applicable methods.
         */
        public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener {
            public boolean onSingleTapUp(MotionEvent e) {
                return false;
            }
    
            public void onLongPress(MotionEvent e) {
            }
    
            public boolean onScroll(MotionEvent e1, MotionEvent e2,
                    float distanceX, float distanceY) {
                return false;
            }
    
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                    float velocityY) {
                return false;
            }
    
            public void onShowPress(MotionEvent e) {
            }
    
            public boolean onDown(MotionEvent e) {
                return false;
            }
    
            public boolean onDoubleTap(MotionEvent e) {
                return false;
            }
    
            public boolean onDoubleTapEvent(MotionEvent e) {
                return false;
            }
    
            public boolean onSingleTapConfirmed(MotionEvent e) {
                return false;
            }
        }
    View Code

    双手指:

    •   如果想要监听单手指操作的全部操作监听
    public class TwoFingerGesture implements ScaleGestureDetector.OnScaleGestureListener {
    
        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public boolean onScaleBegin(ScaleGestureDetector detector) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public void onScaleEnd(ScaleGestureDetector detector) {
            // TODO Auto-generated method stub
            
        }
    
    }
    View Code
    •   如果仅仅想要监听双手指操作的一部分简单操作的监听:
    public class TwoFingerGesture extends ScaleGestureDetector.SimpleOnScaleGestureListener {
    
    }

      

  • 相关阅读:
    PageAdmin CMS内容管理系统V4.0.10版本发布
    CMS建站系统哪个比较好用?
    企业网站建设前需注意的几个事项
    企业网站建设如何用CMS系统快速制作?
    企业网站制作用哪种cms网站管理系统好?
    最受欢迎的cms网站内容管理系统排行榜
    论生成静态和Http缓存优劣势
    用pageadmin cms系统进行网站制作的经验总结
    企业网站制作常用CMS网站内容管理系统推荐
    百科营销的出路在何方?
  • 原文地址:https://www.cnblogs.com/could-deng/p/5050860.html
Copyright © 2020-2023  润新知