谷歌眼镜的手势检测器和setbasellistener



我想实现的手势检测器设置basellistener为我的谷歌眼镜。Android studio给了我一个错误,说符号touchpad找不到。我已经导入了相关的库。

setBaseListener继续给出错误。

private GestureDetector createGestureDetector(Context context,  GestureDetector.OnGestureListener listener) {
    GestureDetector gestureDetector = new GestureDetector(context, listener);
    //Create a base listener for generic gestures
    gestureDetector.setBaseListener(new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            if (gesture == Gesture.TAP) {
                // do something on tap
                return true;
            } else if (gesture == Gesture.TWO_TAP) {
                // do something on two finger tap
                return true;
            } else if (gesture == Gesture.SWIPE_RIGHT) {
                // do something on right (forward) swipe
                return true;
            } else if (gesture == Gesture.SWIPE_LEFT) {
                // do something on left (backwards) swipe
                return true;
            }
            return false;
        }
    });

您的代码格式有点偏离,但似乎您正在将" gestredetector "初始化为

GestureDetector.OnGestureListener listener) { GestureDetector gestureDetector = new GestureDetector(context, listener);

然而,根据谷歌眼镜GDK文档https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/touchpad/GestureDetector

我只看到一个构造函数:public gestredetector (Context Context)

取决于你在哪里构建这个,你可以试试

GestureDetector gestureDetector = new GestureDetector(context);

GestureDetector gestureDetector = new GestureDetector(this);

包含以下导入:

import com.google.android.glass.touchpad.Gesture;
import com.google.android.glass.touchpad.GestureDetector;

相关内容

  • 没有找到相关文章

最新更新