使用 Android 检测长按 [英] Detecting a long press with Android
本文介绍了使用 Android 检测长按的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
onTouchEvent(MotionEvent event){
}
检测用户何时按下我的 glSurfaceView 有没有一种方法可以检测何时进行了长按.我猜如果我在开发文档中找不到太多内容,那么这将是某种解决方法.类似于注册 ACTION_DOWN 并查看距离 ACTION_UP 多长时间.
to detect when the user presses my glSurfaceView is there a way to detect when a long click is made. I'm guessing if I can't find much in the dev docs then it will be some sort of work around method. Something like registering ACTION_DOWN and seeing how long it is before ACTION_UP.
你如何使用 opengl-es 在 android 上检测长按?
How do you detect long presses on android using opengl-es?
推荐答案
试试这个:
final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
public void onLongPress(MotionEvent e) {
Log.e("", "Longpress detected");
}
});
public boolean onTouchEvent(MotionEvent event) {
return gestureDetector.onTouchEvent(event);
};
这篇关于使用 Android 检测长按的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文