标签:
暂时支持viewpager
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1021/1813.html
/* * Date: 14-7-17 * Project: Access-Control-V2 */ package cn.irains.access_control_v2.common; import android.support.v4.app.Fragment; /** * Author: msdx (645079761@qq.com) * Time: 14-7-17 下午5:46 */ public abstract class LazyFragment extends Fragment { protected boolean isVisible; /** * 在这里实现Fragment数据的缓加载. * @param isVisibleToUser */ @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if(getUserVisibleHint()) { isVisible = true; onVisible(); } else { isVisible = false; onInvisible(); } } protected void onVisible(){ lazyLoad(); } protected abstract void lazyLoad(); protected void onInvisible(){} }
Fragment的setUserVisibleHint方法实现懒加载
标签:
原文地址:http://www.cnblogs.com/weidingqiang/p/5226410.html