gpt4 book ai didi

java - 谷歌眼镜 gestureDetector 和 setBaseListener

转载 作者:行者123 更新时间:2023-11-30 02:09:14 24 4
gpt4 key购买 nike

我想实现 gesturedetector 来为我的 Google Glass 设置 baselistener。 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;
}
});

最佳答案

您的代码格式有点不对,但您似乎正在将“gestureDetector”初始化为

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

但是,根据 Glass GDK 文档,位于 https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/touchpad/GestureDetector

我只看到一个构造函数:public GestureDetector (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;

关于java - 谷歌眼镜 gestureDetector 和 setBaseListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30344297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com