Android-ViewPager, androidviewpage
The ViewPager class comes from the supported libraries. Unlike the fragment class, ViewPager only exists in the supported libraries. Moreover, it is foreseeable that there is no standard ViewPager class even in later versions of the SDK.
Android programming authoritative guide
ViewPager is somewhat similar to AdapterView (the super class of ListView) to some extent ). AdapterView can be provided only by Adapter. Similarly, ViewPager also requires PagerAdapter support.
However, the coordination between ViewPager and PagerAdapter is much more complex than that between AdapterView and Adapter. Fortunately, the subclass of PagerAdapter can be used ---FragmentStatePagerAdapterTo handle many details.
FragmentStatePagerAdapter supports the combination of the two methods, namely getCount () and getItem (int ).
By default, ViewPager loads the list items on the current screen and the data on the left and right adjacent pages to implement Quick Page switching. You can call the setOffscreenPageLimit (int) method to customize the number of pre-loaded adjacent pages.
By default, ViewPager only displays the first list item in PageAdapter. You can call setCurrentItem (int) of ViewPager to specify the page to be displayed.