What is the correct way to load data in ViewPager

make a linked page with tablayout and ViewPager

I judge the position in the instantiateItem of the ViewPager adapter to load the network data

but I don"t know why data loaded with position 0 will end up on position 1

I checked the information and said that I wanted to update the data in the addOnPageChangeListener of ViewPager, but I was a little confused about how to update it in onPageSelected

ask for advice on the correct way to load data. Thank you

Mar.14,2021

you post the code


"but I don't know why the data loaded with position 0 will be on position 1". Just subtract 1 when you get the data, like this:
data.get (position-1)


FragmentPagerAdapter / FragmentStatePagerAdapter learn about
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37e53-2c0d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37e53-2c0d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?