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;
            }
        }
    
    }
  • 相关阅读:
    iOS开发——Xcode快捷键
    iOS开发——国际化支持Localizable.strings
    SQL 函数
    常用窗体表单布局
    Extjs grid combo
    怎么完全卸载sql2005?
    ExtJS文件上传
    ExtJS视频学习笔记
    ExtJS问题集——Menu的show()和showBy()函数是什么意思
    C# DataGridView操作
  • 原文地址:https://www.cnblogs.com/20193925zxt/p/14909538.html
Copyright © 2011-2022 走看看