关于Fragment重叠问题解决

2017-08-25  本文已影响0人  Keul


1.

@Override 

protected void onSaveInstanceState(Bundle outState) {

//super.onSaveInstanceState(outState);

}

2.

@Override

public voidonAttachFragment(Fragment fragment) {

super.onAttachFragment(fragment);

if(mainFragment==null&& fragmentinstanceofMainFragment)

mainFragment= (MainFragment) fragment;

if(antStoreFragment==null&& fragmentinstanceofAntStoreFragment)

antStoreFragment= (AntStoreFragment) fragment;

if(shoppingFragment==null&& fragmentinstanceofShoppingFragment)

shoppingFragment= (ShoppingFragment) fragment;

if(mineFragment==null&& fragmentinstanceofMineFragment)

mineFragment= (MineFragment) fragment;

}

3

protected void onSaveInstanceState(Bundle outState) {

FragmentTransaction transaction = fm.beginTransaction();

transaction.remove(tab1);

transaction.remove(tab2);

transaction.remove(tab3);

transaction.remove(tab4);

transaction.commitAllowingStateLoss();

super.onSaveInstanceState(outState);

}

上一篇 下一篇

猜你喜欢

热点阅读