Reputation: 2343
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.
Upvotes: 0
Views: 1970
Reputation: 2303
You can call ViewPager.setOffscreenPageLimit(k)
to cache all entities of ViewPager from n-k to n+k.
Upvotes: 3
Reputation: 1242
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.
Upvotes: 1