zoukankan      html  css  js  c++  java
  • 单手指和双手指(手势探测器)

    单手指:

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

      

    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 {
    
    }

      

  • 相关阅读:
    Elasticsearch、Logstash和Kibana Windows环境搭建(一)
    20200820--1维数组 年龄与疾病(奥赛一本通P78 5)
    20200820--1维数组 数组逆序重放(奥赛一本通P77 4)
    20200820--一维数组:与指定数字相同的数的个数(奥赛一本通P75 1)
    20200819--金币 奥赛一本通P73 10 已讲
    20200818-数1的个数(奥赛一本通 P69 5)
    bits/stdc++.h
    数1的个数(奥赛一本通 P69 5)
    函数和方法的讲解
    20200817-与7无关的数(奥赛一本通 P68 4)
  • 原文地址:https://www.cnblogs.com/could-deng/p/5050860.html
Copyright © 2011-2022 走看看