I've viewpager that has 604 webviews and i want to load 5 pages every time that user scrolling the pager, like that:
{...[4][5][6][7][8]...}
I assume that the current page that selected by user is page 6, so i want to load 2 pages before and after the selected one. I used this built-in method viewPager.setOffscreenPageLimit(3)
and it doesn't run as expected!
so, any advice will be appreciated.
When dealing with so many complex Fragments you should make sure to use a FragmentStatePagerAdapter.
To load two pages ahead also set
viewPager.setOffscreenPageLimit(2)
instead of3
.You also should make sure that in the
getItem()
method of the adapter thefragments will only be created as needed
.