Fragment生命周期

来源:互联网 发布:已恢复的网络购彩 编辑:程序博客网 时间:2024/05/21 22:29

个人笔记

转载自:http://blog.csdn.net/siyehuazhilian/article/details/16838637


官网帮助文档链接:
 http://developer.android.com/guide/components/fragments.html

主要看两张图,和跑代码

一,Fragment的生命周 

          

二,与Activity生命周期的对比

     

场景演示 : 切换到该Fragment11-29 14:26:35.095: D/AppListFragment(7649): onAttach11-29 14:26:35.095: D/AppListFragment(7649): onCreate11-29 14:26:35.095: D/AppListFragment(7649): onCreateView11-29 14:26:35.100: D/AppListFragment(7649): onActivityCreated11-29 14:26:35.120: D/AppListFragment(7649): onStart11-29 14:26:35.120: D/AppListFragment(7649): onResume屏幕灭掉:11-29 14:27:35.185: D/AppListFragment(7649): onPause11-29 14:27:35.205: D/AppListFragment(7649): onSaveInstanceState11-29 14:27:35.205: D/AppListFragment(7649): onStop屏幕解锁11-29 14:33:13.240: D/AppListFragment(7649): onStart11-29 14:33:13.275: D/AppListFragment(7649): onResume切换到其他Fragment:11-29 14:33:33.655: D/AppListFragment(7649): onPause11-29 14:33:33.655: D/AppListFragment(7649): onStop11-29 14:33:33.660: D/AppListFragment(7649): onDestroyView切换回本身的Fragment:11-29 14:33:55.820: D/AppListFragment(7649): onCreateView11-29 14:33:55.825: D/AppListFragment(7649): onActivityCreated11-29 14:33:55.825: D/AppListFragment(7649): onStart11-29 14:33:55.825: D/AppListFragment(7649): onResume回到桌面11-29 14:34:26.590: D/AppListFragment(7649): onPause11-29 14:34:26.880: D/AppListFragment(7649): onSaveInstanceState11-29 14:34:26.880: D/AppListFragment(7649): onStop回到应用11-29 14:36:51.940: D/AppListFragment(7649): onStart11-29 14:36:51.940: D/AppListFragment(7649): onResume退出应用11-29 14:37:03.020: D/AppListFragment(7649): onPause11-29 14:37:03.155: D/AppListFragment(7649): onStop11-29 14:37:03.155: D/AppListFragment(7649): onDestroyView11-29 14:37:03.165: D/AppListFragment(7649): onDestroy11-29 14:37:03.165: D/AppListFragment(7649): onDetach切换到别的activity返回...........................................: onResume 


比Activity多了一些生命周期,完整和Activity对接上,大家好好利用。

1 0