fragment嵌套recyclerview,recyclerview的item重复加载怎么解决
展开全部
fragmentManager默认缓存三个页面,即当前和相邻的页面,切到3或4就会导致重新走oncreateview(),数据没清空就重载咯。在@Override
public boolean getUserVisibleHint() {//适用FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();transaction.hide(from).show(to).commitAllowingStateLoss();
return super.getUserVisibleHint();
}
@Override
public void onHiddenChanged(boolean hidden) {//适用于viewpager
super.onHiddenChanged(hidden);
}
进行数据管理
public boolean getUserVisibleHint() {//适用FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();transaction.hide(from).show(to).commitAllowingStateLoss();
return super.getUserVisibleHint();
}
@Override
public void onHiddenChanged(boolean hidden) {//适用于viewpager
super.onHiddenChanged(hidden);
}
进行数据管理
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询