zoukankan      html  css  js  c++  java
  • 4月6日学习日志

    今天学习了手势的基本操作。

    代码如下:

    public class MainActivity extends AppCompatActivity {
    
        private MyGestureListener mgListener;
        private GestureDetector mDetector;
        private final static String TAG = "MyGesture";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            //实例化GestureListener与GestureDetector对象
            mgListener = new MyGestureListener();
            mDetector = new GestureDetector(this, mgListener);
    
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            return mDetector.onTouchEvent(event);
        }
    
        //自定义一个GestureListener,这个是View类下的,别写错哦!!!
        private class MyGestureListener implements GestureDetector.OnGestureListener {
    
            @Override
            public boolean onDown(MotionEvent motionEvent) {
                Log.d(TAG, "onDown:按下");
                return false;
            }
    
            @Override
            public void onShowPress(MotionEvent motionEvent) {
                Log.d(TAG, "onShowPress:手指按下一段时间,不过还没到长按");
            }
    
            @Override
            public boolean onSingleTapUp(MotionEvent motionEvent) {
                Log.d(TAG, "onSingleTapUp:手指离开屏幕的一瞬间");
                return false;
            }
    
            @Override
            public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
                Log.d(TAG, "onScroll:在触摸屏上滑动");
                return false;
            }
    
            @Override
            public void onLongPress(MotionEvent motionEvent) {
                Log.d(TAG, "onLongPress:长按并且没有松开");
            }
    
            @Override
            public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
                Log.d(TAG, "onFling:迅速滑动,并松开");
                return false;
            }
        }
    
    }
  • 相关阅读:
    接口与抽象类的区别
    全排列(按字典序)
    设置mysql数据库的密码
    android中操作SQLite注意事项
    Android: Fragment详解
    android设置组件所占的比例
    九度oj 1482:玛雅人的密码
    ACM模板
    洛谷 P1156 垃圾陷阱
    AtCoder Beginner Contest 187 F
  • 原文地址:https://www.cnblogs.com/20193925zxt/p/14909538.html
Copyright © 2011-2022 走看看