Android ListView 滑动操作,如 Twitter 列表
I'm trying to implement the "swipe for action" feature - like you can see in the "new" twitter app. A closer description you find at swipe for action description.
Now, are there any ideas/solution how to implement this feature?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在每行中使用
GestureDetector
,并将行内容本身包装在ViewFlipper
中。通过滑动,切换ViewFlipper
的子级。我有一个
ViewSwiper
,它结合了GestureDetector
和 ViewFlipper,但它被设计为在任一方向上工作(例如,从常规行向左或向右滑动将切换到操作),这可能或可能并不理想。但是,它应该让您了解这是如何工作的。Use a
GestureDetector
in each row, and wrap the row contents itself in aViewFlipper
. On a swipe, switch children of theViewFlipper
.I have a
ViewSwiper
that combines aGestureDetector
andViewFlipper
, but it is designed to work in either direction (e.g., from the regular row, a swipe left or right would switch to the actions), which may or may not be desirable. But, it should give you an idea of how this might work.我做了一些与您需要的类似的事情 - 您可以找到一些有关那里的信息。我在那里做了一些手动的事情,但效果很好。为了您的方便,这里是我使用的代码:
I did something similiar to what you need - you can find some info about there. I'm doing some manual stuff there but it works nice. For your convenience here is the code I've used: