Search code examples
androidfragmentstatepageradapter

Android -FragmentStatePagerAdapter change amount of Fragments instantiated


FragmentStatePagerAdapter creates about 3 fragments each time. I'd like it to create say 10 fragments to populate the viewpager at once. I dont see any methods to change the default. Im dealing with a large number of items and each fragment in the adapter makes a network call thus some overhead on each new page traversal. I'd like to cut it down by keeping more items in the adapter at once.


Solution

  • Get a hold of your ViewPager and use setOffscreenPageLimit(10);