获得一个简单的猛击手势

发布于 2024-11-10 07:06:19 字数 697 浏览 0 评论 0原文

因此,这一半是操作方法问题,一半是最佳实践问题。

首先,如果我只想进行简单的“向右滑动”(这将返回到上一个活动),我应该实现 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山有枢 2024-11-17 07:06:19

假设您有机会阅读 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 而不是

viewFlipper.setInAnimation(slideLeftIn);
viewFlipper.setOutAnimation(slideLeftOut);
viewFlipper.showNext();

希望有帮助。

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

viewFlipper.setInAnimation(slideLeftIn);
viewFlipper.setOutAnimation(slideLeftOut);
viewFlipper.showNext();

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文