FragNav icon indicating copy to clipboard operation
FragNav copied to clipboard

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

Open mohammadrezas4 opened this issue 6 years ago • 4 comments

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 ?

mohammadrezas4 avatar Dec 29 '18 11:12 mohammadrezas4

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 avatar Apr 23 '19 21:04 jeffreyfjohnson

@mohammadrezas4 try adding this line when you initialize your FragNavController

fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH

jeffreyfjohnson avatar Apr 23 '19 21:04 jeffreyfjohnson

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

inv-jithin avatar Jun 18 '19 14:06 inv-jithin

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

Harin-Kaklotar avatar Jan 01 '20 09:01 Harin-Kaklotar