android – How to load all fragments in ViewPager

Question:

ViewPager loads side fragments, I need it to load all the fragments that are, how to implement this? (needed to implement ImageSlider)

Answer:

By default, the ViewPager loads the on-screen item, as well as one sibling in each direction, so that the scroll gesture responds immediately. The number of adjacent pages to load can be adjusted by calling setOffscreenPageLimit (int) .

p. 238 – Phillips B., Stuart K., Marsicano K. Android. Programming for professionals. 3rd ed.

Example

mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setOffscreenPageLimit(4);
Scroll to Top