当前位置: 代码迷 >> 综合 >> DialogFragment show()如何防止Can not perform this action after onSaveInstanceState
  详细解决方案

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

热度:55   发布时间:2023-12-14 02:15:10.0
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);

  相关解决方案