ViewPager in TabFragment is not loading a second time

前端 未结 3 601
别那么骄傲
别那么骄傲 2020-12-12 22:13

I\'m trying to make an app that has a ViewPager in a Fragment that is part of a TabHost. Everything works out fine. I have my tabbar, I can switch

相关标签:
3条回答
  • 2020-12-12 22:26

    you should use getChildFragmentManager() instead of getFragmentManager() and FragmentStatePagerAdapter() instead of FragmentPagerAdapter().Hope it will be useful for someone.

    0 讨论(0)
  • 2020-12-12 22:34

    I been searching this for long finally found a solution.Change your page adapter instance FragmentPagerAdapter to FragmentStatePagerAdapter example:

    class PageAdapter extends FragmentStatePagerAdapter {
    
    0 讨论(0)
  • 2020-12-12 22:38

    I found the problem. It took me two days, but hey, it's fixed.

    Instead of using

    mAdapter = new AlbumAdapter(getFragmentManager(), mActiveProject.getInspiration());
    

    You should use

    mAdapter = new AlbumAdapter(getChildFragmentManager(), mActiveProject.getInspiration());
    

    So much for 5 characters.

    0 讨论(0)
提交回复
热议问题