DialogFragment show()如何防止Can not perform this action after onSaveInstanceState

来源:互联网 发布:禁止软件打开 编辑:程序博客网 时间:2024/05/23 09:58
DialogFragment show()如何防止Can not perform this action after onSaveInstanceState 
普通的fragment 可以使用commitallowstatsloss 

DialogFragment 如何防止


   DialogParent dialogTag = (DialogParent) getSupportFragmentManager().findFragmentByTag("dialog_event");
        final DialogParent dialogParent = (dialogTag == null ? DialogParent.getInstance(dialog) : dialogTag);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        if (dialogTag == null) {
            dialogParent.setCancelable(false);
            transaction.add(dialogParent, "dialog_event");
            transaction.commitAllowingStateLoss();
        }
        transaction.show(dialogParent);

0 0
原创粉丝点击