简体   繁体   English

Android如何通过滑动手势实现视图组的更改

[英]Android How to implement a change of viewgroup by swipe gesture

When using gmail or greader, you can go from one message/news to the next/previous by issuing a swipe gesture. 使用gmail或greader时,您可以通过发出滑动手势从一个消息/新闻转到下一个/上一个。

I wonder how is this behavior best implemented? 我想知道这种行为如何最好地实施? Is there some built-in view that does that or should I choose the source and destination views and make a transition between them? 是否有一些内置视图可以做到这一点,还是应该选择源视图和目标视图并在它们之间进行转换?

Any code example going around for this? 有没有代码示例?

Moreover, let's say I want to swipe from a list to a second list. 而且,假设我想从列表滑动到第二个列表。 And when in a tablet I want both lists displayed side by side. 在平板电脑中,我希望两个列表并排显示。 Is this a typical fragment usage? 这是典型的片段用法吗? Still, how to implement the swipe thing? 还是,如何实现滑动的东西?

You need to look at the ViewPager . 您需要查看ViewPager A brief overview and sample source is available at the Developer's blog entry Horizontal View Swiping with ViewPager . 开发人员的博客文章Horizo​​ntal View Swiping with ViewPager提供了简要概述和示例源。

I want to swipe from a list to a second list. 我想从列表滑动到第二个列表。 And when in a tablet I want both lists displayed side by side. 在平板电脑中,我希望两个列表并排显示。 Is this a typical fragment usage? 这是典型的片段用法吗?

It would be better to use Fragment in the above use case. 在上面的用例中使用Fragment会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM