美文网首页
关于Fragment重叠问题解决

关于Fragment重叠问题解决

作者: Keul | 来源:发表于2017-08-25 18:32 被阅读0次


    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);

    }

    相关文章

      网友评论

          本文标题:关于Fragment重叠问题解决

          本文链接:https://www.haomeiwen.com/subject/nyvxqxtx.html