Viewpager Lazy load data

后端 未结 3 1541
灰色年华
灰色年华 2021-01-27 08:54

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

相关标签:
3条回答
  • 2021-01-27 08:59

    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.

    0 讨论(0)
  • 2021-01-27 09:00

    Just like this.

    public class FragmentSample extends Fragment{
        ...  
        @Override
        public void setUserVisibleHint(boolean isVisibleToUser) {
            super.setUserVisibleHint(isVisibleToUser);
            if (isVisibleToUser) {
               // load you data
            }
        }
        ...
    }
    
    0 讨论(0)
  • 2021-01-27 09:12

    Lazy load data for ViewPager Items

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

    0 讨论(0)
提交回复
热议问题