0

I want to replace a fragment inside a ViewPager and this is the code I use:-

mPagerAdapter.startUpdate(mPager);
getSupportFragmentManager()
    .beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
    .remove(old_fragment)
    .add(mPager.getId(), Plain.newInstance(0)) //Plain.newInstance(int) returns a Fragm
    .commit();
mPagerAdapter.notifyDataSetChanged();
mPagerAdapter.finishUpdate(mPager);

and I get this error:- Fragment <MyFragment> is not currently in the FragmentManager

0 Answers0