I have got a ViewPager
which is populated by a FragmentPagerAdapter
. I want to change from the first adapter two another. The problem is that all pages which were loaded before (while having the first adapter) are still the old ones.
I looked at the source code of FragmentPagerAdapter
and guess the problem occurs because of the instatiateItem()
implementation. Using the tag, which has position and conatiner id in it, the method checks if there is already a Fragment
at the position. When there is a Fragment
with this tag it is attached. The container id and position do not change when setting a new adapter so it finds the old Fragment
s.
Do you know a way to remove all old fragments?