getItem(int position) is called to load (attach) a fragment to its position in the fragment pager. By default, not only the visible fragment is loaded, but also the next and previous. Therefore, when you go to the second page, you will see that it loads the third. When you go to the 3rd, it will unload the 1st fragment and load the 4th. When you return to the second fragment, load the first fragment again. And so on.
Nickl source share