How can I disable the preloading in a viewpager?

android, android-viewpager

Solution

How can I disable the preloading in a ViewPager?.

it is not possible. ViewPager preloads always at least 1 page. If you don't want this behaviour you should not use the ViewPager. You could use, for instance, a `RecyclerView`

Old answer

you have to call setOffscreenPageLimit(1)

From the doc

Set the number of pages that should be retained to either side of the current page in the view hierarchy in an idle state. Pages beyond this limit will be recreated from the adapter when needed.

Problem

How can I disable the preloading in a viewpager?. I have a viewpager with 3 pages. So i dont want load the next page and previously page. How can i disable that behavior?

Original source