質問

I had a quick question about how to design my application. All I have now is a simple side navigation menu with a couple options. I understand how this works - the user clicks one, a fragment transaction occurs that replaces the content frame with whatever fragment relates to what the user selected.

What I actually want is for each of these side menu options to replace the content frame with a viewpager which has tabs to swipe between. (So fragments inside fragments?) For example, the user would be able to select 'View Categories' on the side nav menu, and the content frame would have tabs to let him swipe between each category.

Hopefully you can understand that - I'm trying to understand how to design my app to work like this. From what I understand viewpagers are usually are attached to activities, so would that mean each option in my side menu would need to call a new activity?

役に立ちましたか?

解決

Nested fragments (i.e., fragments that contain fragments) are available natively in v17+ devices (android.app.Fragment.getChildFragmentManager()) or available via the Support Library (android.support.v4.app.Fragment.getChildFragmentManager() all the way back to Android 1.6 (v4) - just pass in the FragmentManager returned by getChildFragmentManager() when creating your FragmentPagerAdapter to be used with your ViewPager from within your Fragment.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top