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);
}
进行数据管理