0

First - sorry for the newbish question.

I've started building an app that has a single Activity and a navigation drawer. Each menu item loads a new fragment in the middle frame layout.

I want to create another fragment that:

  1. has tabs
  2. allows for swipe scrolling

It seems like the only way to do this is to create add a ViewPager and PagerTabStrip. All the tutorials I've read indicate the ViewPager requires extending out to FragmentActivity. I have a few questions:

  1. Am I doing anything wrong by replacing the fragment content when navigating menu options?
  2. If what I am doing is ok, is there anyway to incorporate swipe navigation without calling FragmentActivity?
  3. If I need to use FragmentActivity for this one page, I'm assuming I'll call change pages via Intent. Doing so would result in losing the click actions in the navigation drawer. Do I have to call (or duplicate) my code from one activity to another?

EDIT

Sorry about the confusion. Here's what I'd like my application do:

  1. Open app. MainActivity starts. Navigation drawer loads. Main content is loaded via a fragment.
  2. User opens navigation drawer and selects this new menu item I'm creating. It is a new fragment that loads in the frame (like the other menu items). However, it has tabs and supports swiping.
lio-evilo
  • 23
  • 3

1 Answers1

0

ViewPager is just usual descendant of View so it can't require using of FragmentActivity.

  1. It's absolutely ok.
  2. You don't need to use FragmentActivity. I suppose you just read tutorial about "Implementation of drawer" where author of the tutorial used FragmentActivity.
  3. Can't understand what do you mean. Pages of ViewPager is just views not activities. You don't need to use Intent.

PS Actually I can't understand your problem at all. It's absolutely unclear why you don't want to use FragmentActivity.

eleven
  • 6,779
  • 2
  • 32
  • 52
  • Sorry I'm not very clear. The PagerTabStrip will be calling other fragments within the ViewPager. The part I'm confused about is the examples (like this one: https://maxalley.wordpress.com/2013/05/18/android-creating-a-tab-layout-with-fragmenttabhost-and-fragments/) which requires using getSupportFragmentManager(). This is an extension of FragmentActivity. – lio-evilo Mar 05 '15 at 22:53
  • So? `SupportFragmentManager` is just for old versions for android. What's the problem? – eleven Mar 05 '15 at 23:02
  • grrrr i'm a dummy. I posted the wrong link - but there is no problem. My issue was my pager adapter class was extending FragmentPagerAdapter. extending FragmentPagerAdapter requires a constructor with fragmentmanager being passed. When setting my ViewPager adapter I needed to pass the fragment manger, which my fragment did not have. I forgot getActivity().. that's all. =) Thanks for your patience and for answering my question on how I'm using fragments. – lio-evilo Mar 05 '15 at 23:52
  • I also realize without posting code explaining my issue makes things difficult! I've noted this for future posts of mine. – lio-evilo Mar 05 '15 at 23:53
  • There is `PagerAdapter` which does not require `FragmentManager`: http://developer.android.com/intl/ru/reference/android/support/v4/view/PagerAdapter.html :) Fragment related classes could as help you but also could be a problem. – eleven Mar 06 '15 at 00:00