Implementation of PagerAdapter class from the Android compatibility package that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.
This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.
From the documentation of the FragmentStatePagerAdapter
class:
Implementation of
PagerAdapter
that uses aFragment
to manage each page. This class also handles saving and restoring of fragment's state.This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to
FragmentPagerAdapter
at the cost of potentially more overhead when switching between pages.When using FragmentPagerAdapter the host ViewPager must have a valid ID set.
Subclasses only need to implement
getItem(int)
andgetCount()
to have a working adapter.
Tag Usage:
android android-viewpager android-pageradapter fragmentpageradapter android-fragments