简体   繁体   English

如何在Fragments之间实现滑动手势?

[英]How to implement a swipe-gesture between Fragments?

I would like to implement in my android app that I'm developing with the Android studio ide. 我想在我的Android应用程序中实现我正在使用Android studio ide进行开发。 The swipe between the different tabs (fragment). 不同选项卡(片段)之间的滑动。 I tried searching online and on StackOverflow but I could not quite understand. 我尝试在线搜索和StackOverflow,但我不太明白。 My action bar is the classic one that works with Android above 3.0 If you can give me some advice or examples of aid etc. I shall be very grateful. 我的操作栏是经典的,适用于3.0以上的Android。如果你能给我一些建议或帮助等的例子,我将非常感激。 With this I thank you. 有了这个我感谢你。

I suppose the Android ViewPager is what you are looking for: 我想Android ViewPager就是你要找的东西:

http://developer.android.com/reference/android/support/v4/view/ViewPager.html http://developer.android.com/reference/android/support/v4/view/ViewPager.html

Here is a nice tutorial on how to implement it: 这是一个关于如何实现它的很好的教程

http://developer.android.com/training/animation/screen-slide.html http://developer.android.com/training/animation/screen-slide.html

The basic idea is that you have multiple Fragments, each representing a different Screen. 基本思想是你有多个片段,每个片段代表一个不同的屏幕。 The ViewPager enables the user to swipe between the different Fragments and display different content. ViewPager使用户可以在不同的片段之间滑动并显示不同的内容。

Also take a look at this question: 另请看一下这个问题:

How to implement a ViewPager with different Fragments / Layouts 如何使用不同的片段/布局实现ViewPager

And how to include the Support-Library: http://developer.android.com/tools/support-library/setup.html 以及如何包含Support-Library: http//developer.android.com/tools/support-library/setup.html

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

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