0

How can I load next page content of a ViewPager before paging. Imagine I'm using a ViewPager to display a book and each page is a fragment which is added to the ViewPager and I want the fragment being loaded before paging the book and user didn't feel the lag while paging the book page.

Soheil Setayeshi
  • 2,343
  • 2
  • 31
  • 43

2 Answers2

3

You can call ViewPager.setOffscreenPageLimit(k) to cache all entities of ViewPager from n-k to n+k.

Desert
  • 2,293
  • 15
  • 16
1

ViewPager itself handles it.. For instance, if you are currently at item n, the FragmentPagerAdapter calls the onCreateView() of fragments at n-1, n and n+1.

Abhishek Shukla
  • 1,242
  • 8
  • 11