java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState with DialogFragment

后端 未结 10 1207
孤独总比滥情好
孤独总比滥情好 2020-12-09 01:56

I am facing issue with DialogFragment / getSupportFragmentManager / Android version 4.x

01-10 19:46:48.228: E/AndroidRuntime(9879): java.lang.IllegalStateExc         


        
10条回答
  •  無奈伤痛
    2020-12-09 02:34

    fragmentView.post(() -> {
        FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
        YourDialog yourDialog = YourDialog.newInstance();
        yourDialog.show(ft, "text_data");
    });
    

    The goal of post() method in this case is to wait while onResume() of Activity or Fragment will finished. It works if you want to show DialogFragment from Fragment., f.e. when you want to show your dialog after a system dialog dismissed.

提交回复
热议问题