46.1 An Introduction to the ViewPager2 Class
Although not part of the design support library, the ViewPager2 class 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 class 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 a ViewPager2 instance are managed by an instance of the FragmentStateAdapter class.
At a minimum the pager adapter assigned to a ViewPager2 declaration 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.