美文网首页
DialogFragment调用show()出现异常: Ille

DialogFragment调用show()出现异常: Ille

作者: bozo | 来源:发表于2016-09-28 15:39 被阅读0次

              这样会出错,因为onSaveInstanceState方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就是把commit()方法替换成 commitAllowingStateLoss()就行了

    ```

    CustomFragmentDialog voucherFragmentDialog = ustomFragmentDialog.newInstance(sourceType);

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

    fragmentTransaction.add(voucherFragmentDialog,VoucherFragmentDialog.class.getName());

    fragmentTransaction.commitAllowingStateLoss();

    ```

    相关文章

      网友评论

          本文标题:DialogFragment调用show()出现异常: Ille

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