Android Master / Detail interface inside ViewPager

I ran into a problem that I cannot solve, I searched a lot, but could not find a solution.

In my application, I have a ViewPager that contains 3 pages. These pages are fragments of what they should be. It works well. However, two of these pages must be Master / Detail streams (one for friends list, one for news feeds). When I create a master / detail stream with eclipse 2 fragments and 2 actions are created. The ItemListActivity element (the one to be shown) implements the Callbacks fragment, and this is Activity, but the ViewPager only accepts fragments within itself.

So the question is: how can I put Master / Detail Flow inside the ViewPager?

All help is much appreciated! Here I have all the ideas.

thank

+5
source share
1 answer

Master / Detail Flow is just an alias for 2 fragments used in the same kind of content, one on the left and one on the right. This is a general idea. Now the Master / Detail stream can be used inside the Activity (for example, Eclipse for the template you described) or inside a fragment, fortunately, since Android 4.2 introduced fragments inside other fragments (this is also supported by the Android compatibility library for an older version of Android).

, Eclipse, Activity ( ) ( ), Eclipse , / . , Eclipse. 2 .

ViewPager , Master/Detail, MasterFragment.

  • 2 : InnerListFragment, InnerDetailFragment. InnerDetailActivity .
  • 2 XML MasterFragment:

    • layout/fragment_master.xml - InnerListFragment <fragment>
    • layout-sw600dp/fragment_master.xml( > 7 ") - InnerListFragment InnerDetailFragment <fragment>.
  • Java, MasterFragment.java , , , 2 .

    • , InnerListFragment. , onClickListener InnerDetailActivity, InnerDetailFragment.

    • , . , MasterFragment, .

. , .

+11

All Articles