Skip to content Skip to sidebar Skip to footer

Viewpager Lazy Load Data

ViewPager has a public function setOffscreenPageLimit (http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit(int)), What is it? Here i

Solution 1:

Just like this.

publicclassFragmentSampleextendsFragment{
    ...  
    @OverridepublicvoidsetUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
           // load you data
        }
    }
    ...
}

Solution 2:

setOffscreenPageLimit() is normally, we use to set limit of pages that will set in idle state. this method we use when you have a long list of pages in view pager. this method keep away to occurred low memory error and also beneficial when you set lazy loading on pager.

Solution 3:

Lazy load data for ViewPager Items

maybe you can see my answer which use setUserVisibleHint() to customer a fragment

Post a Comment for "Viewpager Lazy Load Data"