fragment – Android: FragmentActivity inside FragmentActivity (ScrollView in NavigationBar)-ThrowExceptions

Exception or error:

I have a FragmentActivity which can swipe through several fragments via ViewPager and a FragmentActivity which hosts an ActionBar for navigation.

Now I want to nest the FragmentActivity with the ViewPager in the first fragment of the other FragmentActivity which hosts the ActionBar.

In other words I like to have an ActionBar navigation and in it’s first Tab I’d like to have swipeable fragments.

My problem is how to nest one FragmentActivity in another FragmentActivity. Both work on their own but I don’t get them to work together.

How to solve:

Swipe Gesture applied at Fragment level along with ViewPager with it's default swipe disabled

You can write your own touch interceptor for the fragments inside your view-pager.

However on a second opinion, please see my moqup in the question:

You can have several ViewGroup container preferably FrameLayout, where on each you can add or remove fragments using transactions. The container of the Navigation Panel is different than where the ViewPager is showing:

Keep this ViewPager in a separate fragment that spawns in yet another FrameLayout. in ViewPager here you should not use the FragmentPageAdapter, but a regular PagerAdapter (avoid nesting of fragments). Hence the ViewPager is a parent container for the Views, and not Fragments where they are shown.

The target of the navigation drawer (on item click) will be this second FrameLayout. Keep it simple!!

Similarly you can have a ViewPager inside a first tab of Tab based ViewPager with this new found information.

Leave a Reply

Your email address will not be published. Required fields are marked *