How to load only one page at time in view pager
you can't do that with a standard ViewPager implementation. If you see sources, you will see, that it sets offscreen page limit to 1, if it is less than 1.
public void setOffscreenPageLimit(int limit) {
if (limit < DEFAULT_OFFSCREEN_PAGES) { //DEFAULT_OFFSCREEN_PAGES if 1
Log.w(TAG, "Requested offscreen page limit " + limit + " too small; defaulting to " +
DEFAULT_OFFSCREEN_PAGES);
limit = DEFAULT_OFFSCREEN_PAGES;
}
if (limit != mOffscreenPageLimit) {
mOffscreenPageLimit = limit;
populate();
}
}
You can try to override this method in your custom class.
ViewPager.setOffscreenPageLimit(0) doesn't work as expected
Does ViewPager require a minimum of 1 offscreen pages
Yes. If I am reading the source code correctly, you should be getting a warning about this in LogCat, something like:
Requested offscreen page limit 0 too small; defaulting to 1
Related Topics
How to Create a Resizable Rectangle with User Touch Events on Android
What Will Happen to the Sharedpreferences on Update an Android App
How to Get Current Flavor in Gradle
Linkedlist Put into Intent Extra Gets Recast to Arraylist When Retrieving in Next Activity
Snappy Scrolling in Recyclerview
Move Markers in Google Map V2 Android
Put and Get String Array from Shared Preferences
Android Setting with Textview for Hebrew Text
How to Add Footer to Navigationview - Android Support Design Library
How to Detect Device Is Android Phone or Android Tablet
Activity Layout: Fragment Class: VS Android:Name Attributes
Proguard Causing Runtimeexception (Unmarshalling Unknown Type Code) in Parcelable Class
Current Month Facebook Friends Birthdays in Android
Recyclerview Inside Scrollview Not Scrolling Smoothly