片段生命周期中是否在onAttach上调用? [英] When is onAttach called during the Fragment LifeCycle?

查看:267
本文介绍了片段生命周期中是否在onAttach上调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Fragment-Activity生命周期中,是否 onAttach 被调用?



我知道碎片生命周期但确切时间到了什么时候?



是否碎片对象是启动或何时调用片段管理器?

解决方案

在活动中,第一种方法是onCreate。
onCreate of activity添加片段,此时onAttach被调用。如图中



参考:



参考: https://github.com/xxv/android-lifecycle


Exactly when is onAttach called during the Fragment-Activity lifecycles?

I am aware of the Fragment Life-Cycle but exactly when?

Is it when the fragment object is initiated or when fragment manager is called?

解决方案

In activity the first method is onCreate. onCreate of activity add the fragment and in this moment onAttach is called. like in the picture

Ref: http://baiduhix.blogspot.com.br/2015/08/android-how-to-do-findviewbyid-in.html

EDIT:

updated lifecycle of Android

Ref: https://github.com/xxv/android-lifecycle

这篇关于片段生命周期中是否在onAttach上调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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