Essam Goda Essam Goda - 1 year ago 92
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

Answer Source

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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download