How to implement gesture recognition in android wear

前端 未结 2 1928
遇见更好的自我
遇见更好的自我 2021-02-14 02:53

Hello i\'m looking for how to detect gestures in android wear, in android i use some code like this, but doesn\'t work in android wear.. is there a way to override the default g

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-14 03:40

    Did you checked your code? It works fine. For simple action there is SimpleOnGestureListener that you can use to seed up work (it works on Android Wear as well):

        GestureDetector mDetector;
        mDetector = new GestureDetector(this, new SimpleOnGestureListener() {
    
            //http://developer.android.com/reference/android/view/GestureDetector.SimpleOnGestureListener.html
    //For example:
                    public void onLongPress(MotionEvent ev) {
                        //TODO handle your action
                    }
                });
    
            @Override
            public boolean onTouchEvent(MotionEvent ev) {
                return mDetector.onTouchEvent(ev) || super.onTouchEvent(ev);
            }
    

提交回复
热议问题