GestureDetector 上的 OnUp 事件
我的问题很简单,实现 GestureListener
时 onUp 事件在哪里?
我在手势检测器上有很多事件,不能只使用侦听器的 onUp 事件,因为其中一个事件是需要它的 onSingleTapConfirmed
。
My question is simple, where's the onUp event when implementing a GestureListener
?
I has a lot of events on the gesturedetector, and cannot just consume the onUp event of the listener, cause one of events are the onSingleTapConfirmed
that needs it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试使用
onFling()
。看起来像是一个奇怪的名字,但对我来说,它的工作原理就像onUp()
方法在逻辑上一样有效。或者试试这个方法...Try using
onFling()
. Seems like a weird name but for me, it works as theonUp()
method would logically work. Or try this method...我通过在将 Action 事件传递给
GestureListener
之前读取它来修复它I fixed it by reading the
Action event
before I pass it to theGestureListener
其他答案可以解决问题,也许它们效果很好,但我不认为这些是好的解决方案。
因为我们应该在单个模块中处理事件,这样我们可以更方便地维护或扩展代码。
(顺便说一句,不要使用
onFilng()
,如果你的手指在屏幕上缓慢移动,onFilng()
将不起作用)所以,我的解决方案是重写 GestureDetector:
以及监听器
::)
The other answers can solve the question,maybe they work good,but I don't think those are good solutions.
Because we should deal with the event in a single moudle,so that we can be esaier to maintain or expand the code.
(By the way, don not use
onFilng()
,if your finger move slowly on the screen,onFilng()
wouldn't work)So,my solution is rewriting the GestureDetector:
And the listener:
: )
您是否从 GestureDetector.OnGestureListener 中消耗的其他事件返回了 true?我遇到了这个问题,结果如果你返回 false,系统会假设你不感兴趣并停止向你传递事件,所以你错过了!
Have you returned true from the other events you consume in your GestureDetector.OnGestureListener? I had this problem and it turns out if you return false, the system assumes you aren't interested and stops passing you events, so you miss the up!