Essam Goda Essam Goda - 3 months ago 36
Android Question

I want to disable preloading next page in a ViewPager

How can I disable the preloading in a ViewPager?

I have a ViewPager with 3 pages fragment in each page. So I don't want to load the next page and previous page. How can I disable this behaviour?

I tried


But this is not working.

and tried

public void setMenuVisibility(final boolean visible) {
if (visible) {
// do something nice here

but RecyclerView which in next fragment show this

RecyclerView: No adapter attached; skipping layout

apologize for my English


The minimum value for the off screen limit is 1. what you can do is, handle it yourself using the "setUserVisibleHint" method in your fragments, like for instance.

public void setUserVisibleHint(boolean isVisibleToUser) {
        if (isVisibleToUser)
           // execute your data loading logic.