如何在Activity中实现SimpleOnGestureListener
这主要是一个设计问题。我在 ItemizedOverlay 上实现了 SimpleOnGestureListener,因为我想捕获 onLongPress 事件以及 onDown 和 onTap 事件。一切正常,但现在我需要转换到特定 onLongPress 事件的新活动。在这种特殊情况下,警报对话框不足以满足我的需求。问题是从覆盖层转换到活动并返回覆盖层。通常,它会从一项活动转移到另一项活动,也许还会再回来。此外,我的覆盖类中的代码变得相当长(大约 450 行),因此需要重构和更多的 SRP。我看不到任何方法可以将 SimpleOnGestureListener 从引用它的活动中附加到 Overlay,也看不到 MapView。我看过的大多数例子都是“祝酒”的例子。
This is primarily a design question. I've implemented SimpleOnGestureListener on an ItemizedOverlay because I wanted to catch the onLongPress event as well as the onDown and onTap events. Everything is working okay but now I need to transition to a new activity on a specific onLongPress event. In this particular case an alert dialog is insufficient for my needs. Problem is transitioning from the overlay to an activity and back to the overlay. Usually, its from one activity to another and maybe back again. In addition, the code in my overlay class is getting quite long (about 450 lines) so it needs refactored and a bit more SRP. I can't see any way to attach the SimpleOnGestureListener to the Overlay from within the activity which references it, nor the MapView. Most examples I've looked at are noddy 'make a Toast' examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定我是否正确回答了您的问题,但您可以进行视图间转换,例如使用 ViewFlipper 或带有 fling 检测器的 FrameLayout。
您可以查看 股票计算器管理其转换。
I'm not quite sure if I getting your question right, but you can have inter-view transition, e.g. with ViewFlipper or FrameLayout with a fling detector.
You can look how the stock calculator manage its transition.