文档说这个从Dialog
类dismiss()
方法:如何正确关闭DialogFragment?
Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when the dialog is dismissed, instead implement that in onStop().
在我的代码,我要做的就是调用getDialog().dismiss()
予以驳回。但我没有做任何事情,甚至没有使用onStop()
。所以我正在问如何正确解雇DialogFragment
以避免任何内存泄漏等。
不幸的是,这导致我包含的活动完成... –
@ScootrNova:它不应该,你可能有其他地方的错误。你如何创建片段? – Heinzi
'protected void showDialogFragment(final DialogFragment fragment){final FragmentTransaction fTransaction = getSupportFragmentManager()。beginTransaction(); fTransaction.addToBackStack(NULL); fragment.show(fTransaction,“dialog”);}' 对不起,讨厌的单线!但是,你可能是对的,所以暂时我写了另一种方式来关闭我的DialogFragments。我使用dismiss()方法解雇他们的方式是通过标签找到片段,然后在其上运行dismiss()(如果它不为null)。哦,是的,我在将这个片段传递给这个方法之前,正在对它进行新的分析。 –