获得一个简单的猛击手势
因此,这一半是操作方法问题,一半是最佳实践问题。
首先,如果我只想进行简单的“向右滑动”(这将返回到上一个活动),我应该实现 OnGestureListener 还是使用 GestureOverlayView 执行某些操作?
我读了 网格布局上的 Fling 手势检测 ,看起来如果我使用 OnGestureListener 我必须手动将侦听器添加到我所有的观点。这很烦人,而且我想将此功能添加到许多活动中,所以如果我可以将所有逻辑放入一个独立的函数中,我会很高兴。那么也许 GestureOverlayView 会更可取?但我看到的所有例子都非常复杂......我不想做出自己的手势。我只想要一个简单的滑动/滑动检测,如 网格布局上的滑动手势检测。
其次,如果你主张其中任何一种立场,你能举一个简单的例子吗? 网格布局上的Fling手势检测用于扩展SimpleOnGestureListener而不是实现OnGestureListener,我对实际设置的步骤有点困惑手势监听者听取意见。至于 GestureOverlayView,就像我说的,我所看到的都是创建自己的手势的复杂示例。
So this is half a how-to and half a best practices question.
First, if I just want to get a simple "fling right" (which will go back to a previous activity) should I implement OnGestureListener or do something with GestureOverlayView?
I read Fling gesture detection on grid layout and it looks like if I go with OnGestureListener I'll have to manually add the listener to all my views. This is annoying, plus I'd like to add this functionality to many activities, so i'd be nice if i could fit all the logic in a self contained function. So maybe GestureOverlayView would be preferable? But all the examples I see for it are really complicated... I don't want to make my own gestures. I just want a simple swipe/fling detect as in Fling gesture detection on grid layout.
Secondly, if you advocate either position, can you post a simple example? Fling gesture detection on grid layout is for extending SimpleOnGestureListener not implementing OnGestureListener and I'm a little stuck on the steps for actually setting the gesture listener to listen to views. As for GestureOverlayView, like i said, all I've seen are complicated examples of creating your own gestures.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您有机会阅读 Code Shogun 中的示例:在 onFling() 中,您可以调用 finish() Activity 来代替 ViewFlipper 方法调用。
http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/" codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
因此,调用 finish() Activity 而不是
希望有帮助。
Presuming you've had the chance of going through the example at Code Shogun: In onFling(), you could call finish() Activity in place of ViewFlipper method calls.
http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
So, call finish() Activity instead of
Hope that helps.