理解Fragment生命周期
官网帮助文档链接:
http://developer.android.com/guide/components/fragments.html
主要看两张图,和跑代码
一,Fragment的生命周
二,与Activity生命周期的对比
场景演示 : 切换到该Fragment
11-29 14:26:35.095: D/AppListFragment(7649): onAttach
11-29 14:26:35.095: D/AppListFragment(7649): onCreate
11-29 14:26:35.095: D/AppListFragment(7649): onCreateView
11-29 14:26:35.100: D/AppListFragment(7649): onActivityCreated
11-29 14:26:35.120: D/AppListFragment(7649): onStart
11-29 14:26:35.120: D/AppListFragment(7649): onResume
屏幕灭掉:
11-29 14:27:35.185: D/AppListFragment(7649): onPause
11-29 14:27:35.205: D/AppListFragment(7649): onSaveInstanceState
11-29 14:27:35.205: D/AppListFragment(7649): onStop
屏幕解锁
11-29 14:33:13.240: D/AppListFragment(7649): onStart
11-29 14:33:13.275: D/AppListFragment(7649): onResume
切换到其他Fragment:
11-29 14:33:33.655: D/AppListFragment(7649): onPause
11-29 14:33:33.655: D/AppListFragment(7649): onStop
11-29 14:33:33.660: D/AppListFragment(7649): onDestroyView
切换回本身的Fragment:
11-29 14:33:55.820: D/AppListFragment(7649): onCreateView
11-29 14:33:55.825: D/AppListFragment(7649): onActivityCreated
11-29 14:33:55.825: D/AppListFragment(7649): onStart
11-29 14:33:55.825: D/AppListFragment(7649): onResume
回到桌面
11-29 14:34:26.590: D/AppListFragment(7649): onPause
11-29 14:34:26.880: D/AppListFragment(7649): onSaveInstanceState
11-29 14:34:26.880: D/AppListFragment(7649): onStop
回到应用
11-29 14:36:51.940: D/AppListFragment(7649): onStart
11-29 14:36:51.940: D/AppListFragment(7649): onResume
退出应用
11-29 14:37:03.020: D/AppListFragment(7649): onPause
11-29 14:37:03.155: D/AppListFragment(7649): onStop
11-29 14:37:03.155: D/AppListFragment(7649): onDestroyView
11-29 14:37:03.165: D/AppListFragment(7649): onDestroy
11-29 14:37:03.165: D/AppListFragment(7649): onDetach
比Activity多了一些生命周期,完整和Activity对接上,大家好好利用。
最新文章
- WPF简单模拟QQ登录背景动画
- Web软件安全攻击
- error: linker command failed with exit code 1 解决方法之一
- c# 如何通过反射 获取\设置属性值
- docker 下 安装rancher 笔记
- simplify the life ECMAScript 5(ES5)中bind方法简介
- HTML+CSS笔记 表格,超链接,图片,表单
- Image File Execution Options(转)
- 关于Tarjan(1)
- Python3创建项目时创建了一个叫做“keyword";的包,运行项目时报ImportError: cannot import name 'iskeyword'错误
- ORA-12519 ORA-12516
- Media Queries 媒体查询常见设备断点
- 学了9天java,没什么感觉,有点害怕,总结一下for循环。
- 关于iphone6/5/4s 在iOS8.0系统下 仅仅读@3x图片
- python介绍与入门
- paddle实践
- jQuery选择器遇上一些特殊字符
- Solr系列六:solr搜索详解优化查询结果(分面搜索、搜索结果高亮、查询建议、折叠展开结果、结果分组、其他搜索特性介绍)
- CI框架 -- 配置文件config.php
- DOM事件机制(事件捕获和事件冒泡和事件委托)
热门文章
- BZOJ1083 繁忙的都市
- 洛谷P1203 [USACO1.1]坏掉的项链Broken Necklace
- event driven的一些概念
- jsp中 response和request区别
- 初学JDBC,防SQL注入简单示例
- python 与 mysql
- 远程桌面连接不上|windows server 2003 sp2 termdd.sys(转载)
- Hibernate unsaved-value 属性
- centos下使用eclipse jlink 调试uboot
- 微信内测";微视频"; 朋友圈可以发6-8秒短视频