I am working on Fragments. Fragment1 contains ViewPager. ViewPager has 3 Fragments. when ever I call Fragment1 ViewPager works fine. But if I replace Fragment1 with other Fragment Fragment2 and returns back to Fragment1 using backButton. ViewPager displays nothing. All 3 fragments are added to fragment but onCreateView() is not called and there is no UI for these 3 fragments. I am using FragmentStatePagerAdapter for ViewPager.

Any help will be appreciated.

有帮助吗?

解决方案

I think you are using getFragmentManager() or getSupportFragmentManager() in the Fragment which is calling your ViewPager's pages. Try to use getChildFragmentManager instead.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top