How to add a Fragment inside a ViewPager using Nested Fragment (Android 4.2)

Posted by sabadow on Stack Overflow See other posts from Stack Overflow or by sabadow
Published on 2012-11-14T12:52:52Z Indexed on 2012/11/15 11:01 UTC
Read the original article Hit count: 617

I have a ViewPager with three Fragments, each one shows a List (or Grid).

In the new Android API level 17 (Jelly Bean 4.2), one of the features is Nested Fragments. The new functionality description says:

if you use ViewPager to create fragments that swipe left and right and consume a majority of the screen space, you can now insert fragments into each fragment page.

So, if I understand right, now I can create a ViewPager with Fragments (with a button inside for example) inside, and when user press the button show another Fragment without loose the ViewPager using this new feature.

I expend my morning trying to implement this on several ways but I can´t made it... Can somebody show a simple example of how to do this?

PS: I'm only interested in doing at this way, with getChildFragmentManager to learn how works.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-fragments