0

I've run into a road block with creating a basic app - due to my understanding of fragments and basic app structure. Could you give me an idea for how my app should be structured?

  • I have an app with a navigation drawer (currently in the main activity).
  • The main activity layout has the drawerlayout widget, a frame layout (for fragments), and the list view for the drawer.
  • Each fragment (or class) is selected thru the navigation drawer.

this has worked fine so far, but I have run into a roadblock. I'd like to create a new fragment which would has tabs. Just about every tutorial I've looked at creates an activity that extends FragmentActivity ... this won't work since FragmentActivity is an Activity.

My question is - is the way I'm structuring my app to work wrong? How should I go about implementing this new tabbed activity / fragment?

Please let me know if you need additional details about the app.

user673869
  • 221
  • 1
  • 3
  • 10

2 Answers2

0

You could use a ViewPager with a FragmentStatePagerAdapter, and add a TabStrip on top. The ViewPager can be contained in a separate Fragment, so would meet your requirement.

See this post for further details Display fragment viewpager within a fragment

Community
  • 1
  • 1
Steffen Funke
  • 2,168
  • 1
  • 21
  • 18
0

You might want to consider launching an activity when an item is selected from the navigation drawer. Just call startActivity(your_intent) in the onClick for the navigation drawer item.

This way the new activity can extend FragmentActivity as the tutorials suggest.

mistwalker
  • 781
  • 7
  • 9