什么是DialogFragment的生命周期 [英] What is lifecycle of DialogFragment
问题描述
我无法通过Google搜索找到android.support.v4.app.DialogFragment
的正确生命周期.我需要一些实现.我们知道DialogFragment
具有与Dialog
类似的一些方法.
I could not find proper lifecycle of android.support.v4.app.DialogFragment
by searching on Google. I need this for some implementation. As we know DialogFragment
has some methods same like Dialog
.
DialogFragment
扩展了Fragment
,因此其生命周期与Fragment
相同.但是DialogFragment
的其他方法呢?
DialogFragment
extends Fragment
so its lifecycle is same as Fragment
. But what about other methods of DialogFragment
?
这是Fragment
生命周期.可以提供DialogFragment
吗?
Here is Fragment
lifecycle. Can one provide for DialogFragment
?
推荐答案
DialogFragment
的生命周期类似于 fragment:
的生命周期.为了测试自己,将日志放入 dialogFragment
的每个overrided
方法中,然后运行代码,您将了解dialogFragment
的工作原理.
DialogFragment
life cycle is similar to the life cycle of fragment:
. To test yourself put logs in each of the overrided
methods of dialogFragment
and then run your code you will understand the working of dialogFragment
.
onAttach
onCreate
onCreateDialog
onCreateView
onActivityCreated
onStart
onResume
就完成或销毁dialogFragment而言,生命周期如下:
And as far as finishing or destroying dialogFragment is concerned the lifeCycle is as follows:
onPause
onStop
onDestroyView
onDestroy
onDetach
此外,我相信这种方法也可以帮助您了解lifecycle
:
Also I believe this method will also help you know the lifecycle
:
@NonNull
@Override
public Lifecycle getLifecycle() {
return super.getLifecycle();
}
这篇关于什么是DialogFragment的生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!