Implementation of {@link android.support.v4.view.PagerAdapter} that
represents each page as a {@link Fragment} that is persistently
kept in the fragment manager as long as the user can return to the page.
This version of the pager is best for use when there are a handful of
typically more static fragments to be paged through, such as a set of tabs.
The fragment of each page the user visits will be kept in memory, though its
view hierarchy may be destroyed when not visible. This can result in using
a significant amount of memory since fragment instances can hold on to an
arbitrary amount of state. For larger sets of pages, consider
{@link FragmentStatePagerAdapter}.
When using FragmentPagerAdapter the host ViewPager must have a
valid ID set.
Subclasses only need to implement {@link #getItem(int)}
and {@link #getCount()} to have a working adapter.
Here is an example implementation of a pager containing fragments of
lists:
{@sample development/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java
complete}
The R.layout.fragment_pager resource of the top-level fragment is:
{@sample development/samples/Support4Demos/res/layout/fragment_pager.xml
complete}
The R.layout.fragment_pager_list resource containing each
individual fragment's layout is:
{@sample development/samples/Support4Demos/res/layout/fragment_pager_list.xml
complete} |