Search code examples
androidandroid-fragmentsandroid-viewpagerpagerslidingtabstrip

Viewpager Fragments turning blank


Using a PagerSlidingTabStrip with a Viewpager inside of a fragment:

  • The main Activity contains a "main fragment" that changes depending on what item you click in navigation drawer.
  • When loading the initial fragment containing the Viewpager everything shows up fine (all pages are populated).
  • Replacing that main fragment with another one and then going back to the viewpager fragment turns every page in the viewpager blank, but the PagerSlidingTabStrip tabs are still there.

Any ideas?


Solution

  • I had a problem like that

    try this

    mPager.setAdapter(new BasePagerAdapter(getChildFragmentManager(), getResources()));
    

    you probably have this

    mPager.setAdapter(new BasePagerAdapter(getFragmentManager(), getResources()));
    

    EDIT: and in your BasePagerAdapter extend FragmentStatePagerAdapter

    public class BasePagerAdapter extends FragmentStatePagerAdapter {