zoukankan      html  css  js  c++  java
  • 安卓手势监听处理

     private final GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener(){
    
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                MyToast.makeToast(GestureDetectorActivity.this, "single click!");
                return super.onSingleTapConfirmed(e);
            }
    
            @Override
            public boolean onDoubleTap(MotionEvent e) {
                MyToast.makeToast(GestureDetectorActivity.this, "double click down!");
                return super.onDoubleTap(e);
            }
    
            @Override
            public boolean onDoubleTapEvent(MotionEvent e) {
                switch (e.getActionMasked()){
                    case MotionEvent.ACTION_UP:
                        MyToast.makeToast(GestureDetectorActivity.this, "double click up!");
                        break;
                }
                return super.onDoubleTapEvent(e);
            }
    
            @Override
            public boolean onDown(MotionEvent e) {
                MyToast.makeToast(GestureDetectorActivity.this, "onDown");
                return super.onDown(e);
            }
    
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                mSpeedX = velocityX;
                mSpeedY = velocityY;
                handler.postDelayed(runnable, 30);
                return super.onFling(e1, e2, velocityX, velocityY);
            }
    
            @Override
            public void onShowPress(MotionEvent e) {
                MyToast.makeToast(GestureDetectorActivity.this, "onShowPress");// >150ms 时调用
                super.onShowPress(e);
            }
    
            @Override
            public boolean onSingleTapUp(MotionEvent e) {// 双击第一次抬起触发,第二次不触发
                Log.d("onSingleTapUp", "onSingleTapUp");// >150ms 时调用
                return super.onSingleTapUp(e);
            }
    
            @Override
            public void onLongPress(MotionEvent e) {
                MyToast.makeToast(GestureDetectorActivity.this, "onLongPress");
                // 后续工作
                super.onLongPress(e);
            }
    
            @Override
            public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                MyToast.makeToast(GestureDetectorActivity.this, "onScroll X = " +
                        distanceX + " Y = " + distanceY);
                return super.onScroll(e1, e2, distanceX, distanceY);
            }
            
        };
    

      

  • 相关阅读:
    一点技巧
    题解G
    WA七次,疯了》》》》》OTZ
    就是过不了啊无奈。。。。。水题都过不了…………OTZ OTZ OTZ
    [IOS]使用UIScrollView和UIPageControl显示半透明帮助蒙板
    [System]几种同步方式
    [Objective C] Singleton类的一个模版
    [IOS] 自定义AlertView实现模态对话框
    [IOS] UIKit Animation
    [IOS]使用genstrings和NSLocalizedString实现App文本的本地化
  • 原文地址:https://www.cnblogs.com/ning-blogs/p/11686314.html
Copyright © 2011-2022 走看看