ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

one tab that has a view pager with multi fragment in it #188

Open mohammadrezas4 opened 5 years ago

mohammadrezas4 commented 5 years ago

hi. I have a problem with it. I'm new in android and I have 3 tabs in a BottomBar in my App. one of them has a view pager that scroll between 5 or 6 fragment in it. in the first lunch everything is ok but when I switched between tabs and back to the tab has view pager it shows nothing. view pager is loaded but fragments in it didn't load. what can I do ?

jeffreyfjohnson commented 5 years ago

Running into this same issue. It looks like in this scenario, the FragmentManager still has a reference to all the Fragments in the ViewPager, even though getItem on the ViewPager's FragmentPagerAdapter isn't called besides the first time. I'm guessing the view for these Fragments have been destroyed, but since the FragmentManager still knows about them, they are not getting onViewCreated called, and thus you don't see them.

I'll report back if I get anywhere with this

jeffreyfjohnson commented 5 years ago

@mohammadrezas4 try adding this line when you initialize your FragNavController

fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH
inv-jithin commented 5 years ago

@mohammadrezas4 I have the same issue and resolved the issue by doing the following method. Please pass getChildFragmentManager() to the ViewPagedAdapter. new ViewPagerAdapter(getChildFragmentManager());

Harin-Kaklotar commented 4 years ago

@inv-jithin yes you are absolutely right brother. Thanks for the help.