[整] Android Fragment 生命周期图

时间:2014-07-11 10:23:14   收藏:0   阅读:523

1. onAttach ------called once the fragment is associated with its activity 

2. onCreate-------called to do initial creation of the fragment

3. onCreateView---creates and returns the view hierarchy associated with the fragment

4.onActivityCreated ---tells the fragment that its activity has completed its own {@link Activity#onCreate Activity.onCreaate}

5.onStart----------makes the fragment visible to the user (based on its containing activity being started)

6.onResume-----makes the fragment interacting with the user (based on its containing activity being resumed).

7. onPause----- fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.

8.onStop------fragment is no longer visible to the user either  because its activity is being stopped or a fragment operation is modifying it  in the activity.

9.onDestroyView ------allows the fragment to clean up resources  associated with its View.

10.onDestroy---------called to do final cleanup of the fragment‘s state.

11.onDetach--------called immediately prior to the fragment no longer   being associated with its activity

bubuko.com,布布扣

 

 

Fragment与Activity生命周期对比图:

bubuko.com,布布扣

1. 当一个fragment被创建的时候,它会经历以下状态.

2. 当这个fragment对用户可见的时候,它会经历以下状态。

3. 当这个fragment进入“后台模式”的时候,它会经历以下状态。

4. 当这个fragment被销毁了(或者持有它的activity被销毁了),它会经历以下状态。

5. 就像activitie一样,在以下的状态中,可以使用Bundle对象保存一个fragment的对象。

6. fragments的大部分状态都和activitie很相似,但fragment有一些新的状态。

一旦activity进入resumed状态(也就是running状态),你就可以自由地添加和删除fragment了。因此,只有当activity在resumed状态时,fragment的生命周期才能独立的运转,其它时候是依赖于activity的生命周期变化的。

 

bubuko.com,布布扣

 

 

 

 

 

[整] Android Fragment 生命周期图,布布扣,bubuko.com

原文:http://www.cnblogs.com/androidsj/p/3834297.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!