With a SherlockActionBar i've created a nice interface. In landscape mode you see both listfragment and "detailsfragment".
Now I would like to a add a viewpageindicator (https://github.com/JakeWharton/Android-ViewPagerIndicator) inside the detailsframe, so i would look like this:
--------------------------|
|_1___|TAB1 | TAB2 | ETC |
|_2___|-------------------|
|_3___|Example: content |
|_4___| TAB1 of listitem 1|
|_5___|___________________|
I hope this is clear. So basicly I would a FragmentManager/TabPageIndicator inside a fragment.
I this possible? I can't figure it out.. :(
Thank you!
You can't nest fragments inside fragments. It will be displayed fine, but it will crash when you will want to replace some of them using transactions.
Have a look a these:
You should not put a
Fragment
inside aFragment
. You can however put aViewPager
inside a fragment and get the result you're looking for.I was facing the same issue a while ago for one of my apps (only I wanted the
ViewPager
to contain someListView
s). This was the end result (see the lines; red containsFragment
, blueViewPagerIndicator
, greenViewPager
):I accomplished this with the following steps. Fist, for the detail-fragment, I created the following XML file:
Then, I set up a custom PagerAdapter to populate the ViewPager and the TabPageIndicator:
Next, in my fragment, I set the following: