53.1 An Introduction to the ViewPager2
Although not part of the design support library, the ViewPager2 is a useful companion class when used in conjunction with the TabLayout component to implement a tabbed user interface. The primary role of the ViewPager2 is to allow the user to flip through different pages of information where each page is most typically represented by a layout fragment. The fragments that are associated with the ViewPager2 are managed by an instance of the FragmentPagerAdapter class.
At a minimum the pager adapter assigned to a ViewPager2 must implement two methods. The first, named getItemCount(), must return the total number of page fragments available to be displayed to the user. The second method, createFragment(), is passed a page number and must return the corresponding fragment object ready to be presented to the user.