android: ViewPager with more than 100 webview

2k views Asked by At

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.

1

There are 1 answers

2
Ostkontentitan On

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 of 3.

You also should make sure that in the getItem() method of the adapter the fragments will only be created as needed.