How to implement a swipe-gesture between Fragments?

lillogoal picture lillogoal · Sep 3, 2013 · Viewed 27k times · Source

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.

Answer

Philipp Jahoda picture Philipp Jahoda · Sep 3, 2013

I suppose the Android ViewPager is what you are looking for:

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

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.

Also take a look at this question:

How to implement a ViewPager with different Fragments / Layouts

And how to include the Support-Library: http://developer.android.com/tools/support-library/setup.html