什么是DialogFragment的生命周期 [英] What is lifecycle of DialogFragment

查看:435
本文介绍了什么是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆