Java 如何在片段之间实现滑动手势?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18591265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 09:19:10  来源:igfitidea点击:

How to implement a swipe-gesture between Fragments?

javaandroidandroid-fragmentsandroid-viewpagerswipe

提问by lillogoal

I would like to implement in my android app that I'm developing with the Android studio ide. The swipe between the different tabs (fragment). I tried searching online and on StackOverflow but I could not quite understand. 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. With this I thank you.

我想在我使用 Android Studio ide 开发的 android 应用程序中实现。不同选项卡(片段)之间的滑动。我尝试在网上和 StackOverflow 上搜索,但我不太明白。我的操作栏是Android 3.0以上的经典操作,如果您能给我一些建议或帮助等示例,我将不胜感激。借此我感谢你。

采纳答案by Philipp Jahoda

I suppose the Android ViewPageris 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 tutorialon 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.

基本思想是您有多个 Fragment,每个 Fragment 代表一个不同的 Screen。ViewPager 使用户能够在不同的 Fragment 之间滑动并显示不同的内容。

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