DialogFragment customCurrentDialogFragment; -> custom dialog
从另一个对话框片段(片段A)启动对话框:
FragmentManager fragmentManager = getFragmentManager();
customCurrentDialogFragment = new CustomLoader();
customCurrentDialogFragment.setCancelable(false);
customCurrentDialogFragment.show(fragmentManager, "dialog");
在片段A中解雇:
customCurrentDialogFragment.dismiss();
您可以使用DialogFragment的dismissAllowingStateLoss()
方法。
由于您使用片段管理器调用show()方法,因此可以使用dismissAllowingStateLoss()方法来关闭对话框片段。同时,如果你使用片段事务使用show()方法,这不起作用,因为popBackStack用allowStateLoss = false
调用enqueueAction()