FragmentPagerAdapter is not removing items (Fragments) correctly

前端 未结 9 1407
别跟我提以往
别跟我提以往 2021-01-30 01:30

I have implemented the FragmentPagerAdapter and and using a List to hold all fragments for my ViewPager to display. On

9条回答
  •  忘掉有多难
    2021-01-30 02:08

    Didn't work out for me. My solution was put FragmentStatePagerAdapter.java in my project, renamed to FragmentStatePagerAdapter2.java. In destroyItem(), I changed a little based on error logs. From

    // mFragments.set(position, null);
    

    to

    if (position < mFragments.size())mFragments.remove(position);
    

    Maybe you don't have the same problem, just check the log.Hope this helps someone!

提交回复
热议问题