Can some draw lifecycle of Fragment and its parent FragmentActivity?

雨燕双飞 提交于 2019-12-30 01:35:11

问题


In Android docs, I found a specs on Activity lifecycle and on Fragment lifecycle individually, but never together. It does not seem obvious as I attached a debugger to FragmentActivity which hosts my fragment, and the life cycle is more than crazy. It looks like activity finishes first and then fragments starts, which is impossible.

Fragment's lifecycle


Activity's lifecycle


Logically, fragment should "jump into" activity's lifecycle after its onResume and it would end before activity's onPause, but it seems it is not happening.

Can someone either show me the lifecycle of the fragment in connection to its parent's activity or direct me to some good tutorial on this?


回答1:


Have you seen this? Fragment is created after Activity is created. It doesn't seem possible for "activity finishes first and then fragments starts" Can you post the code for that?
This is what I tested, 1 FragmentActivity , two Fragments :



来源:https://stackoverflow.com/questions/13941584/can-some-draw-lifecycle-of-fragment-and-its-parent-fragmentactivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!