特性可以将一些平局生命周期及其母公司FragmentActivity? [英] Can some draw lifecycle of Fragment and its parent FragmentActivity?

查看:159
本文介绍了特性可以将一些平局生命周期及其母公司FragmentActivity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的文档,我发现活动的生命周期和片段生命周期单独一个规范,但从来没有在一起。它似乎并不明显,因为我连着一个调试器 FragmentActivity 承载我的片段,以及生命周期是多疯狂。它看起来像活动结束,然后再分片启动,这是不可能的。

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

从逻辑上讲,片段应在跳进活动的生命周期及其 onResume ,它会之前结束活动的的onPause ,但似乎这是不会发生。

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?

推荐答案

你见过的这个的?在创建活动后,片段被创建。这似乎并不可能活动结束,然后再分片启动你能后的code是什么?
这是我测试过,1 FragmentActivity,两个片段:

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 :

这篇关于特性可以将一些平局生命周期及其母公司FragmentActivity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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