Android官方文档翻译——Fragment生命周期
网上有的博客写得太乱
不如自己翻译官方文档
Lifecycle
生命周期
Though a Fragment's lifecycle is tied to its owning activity, it has its own wrinkle on the standard activity lifecycle. It includes basic activity lifecycle methods such as onResume(), but also important are methods related to interactions with the activity and UI generation.
虽然Fragmentd的生命周期依赖于拥有它的Activity,但在Activity的生命周期标准上他有自己的一套周期,包括基本的activity生命周期方法,比如onResume(),这些方法也都与activity和ui相互交互。
The core series of lifecycle methods that are called to bring a fragment up to resumed state (interacting with the user) are:
将fragment从运行到resumed状态(与用户交互)的生命周期核心方法是:
1、onAttach(Activity) called once the fragment is associated with its activity.
一旦fragment与activity有联系调用此方法
2.onCreate(Bundle) called to do initial creation of the fragment.
fragment的初始化时调用
3、onCreateView(LayoutInflater, ViewGroup, Bundle) creates and returns the view hierarchy associated with the fragment
创建和返回和fragment有关的视图层级。
4.onActivityCreated(Bundle) tells the fragment that its activity has completed its own Activity.onCreate().
告诉fragment它关联的activity已经完成了自己的onCreate()方法。
5,onViewStateRestored(Bundle) tells the fragment that all of the saved state of its view hierarchy has been restored.
告诉fragment所有的它的视图层级的状态已经存储
6,onStart() makes the fragment visible to the user (based on its containing activity being started).
fragment可见时调用。
7,onResume() makes the fragment interacting with the user (based on its containing activity being resumed).
fragment可以和用户交互
As a fragment is no longer being used, it goes through a reverse series of callback:
当fragment不再使用时,经理一系列反向回调。
1,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.
fragment不再与用户交互,要么因为它关联的activity进入pasused状态,要么因为这个activity正在修改fragment的操作。
2,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.
fragment不再可见,要么因为它关联的activity正在进入stop状态,要么因为这个activity正在修改fragment的操作
3,onDestroyView() allows the fragment to clean up resources associated with its View.
运行fragment与它相关视图的资源
4,onDestroy() called to do final cleanup of the fragment's state.
清除fragment的状态。
5,onDetach() called immediately prior to the fragment no longer being associated with its activity
在Fragment不再和Activity关联之前调用onDetach()
Android官方文档翻译——Fragment生命周期的更多相关文章
- 【Android归纳】Fragment生命周期-基于实验的最新总结
如今非常多应用的开发都是基于FragmentActivity中嵌套Fragment进行开发的,所以,假设我们可以清晰地知道他们的生命周期,那么会使我们的开发变的easy. 对于Activity的生命周 ...
- Android Activity与Fragment生命周期
- Android Activity与Fragment生命周期 对应关系
- Android Fragment 生命周期及其API使用(建议使用自定义View替换Fragment)
我为什么不主张使用Fragment Fragment:( Fragment就相当于一个有生命周期的View,它的生命周期被所在的Activity的生命周期管理 ) 生命周期回调说明: onAttach ...
- Android Fragment 生命周期及其正确使用(建议使用自定义View替换Fragment)
使用Fragment 官方例子中显示: 例如:一个学生Fragment,需要传入studentId,进行http请求显示,那么setArguments后防止杀掉Fragment后,参数为0,显示不了数 ...
- 重温Android和Fragment生命周期
重温下Android和Fragment生命周期,理解生命周期方法的作用,什么时候调用,可以做一些什么操作. 1.Android生命周期 1.1 生命周期图 1.2 生命周期函数说明 onCreate: ...
- Android Activity生命周期以及Fragment生命周期的区别与分析
Android Fragment生命周期图: Activity生命周期图: 对照图: Fragment生命周期分析: 1. 当一个fragment被创建的时候,它会经历以下状态. onAttach() ...
- Android零基础入门第86节:探究Fragment生命周期
一个Activity可以同时组合多个Fragment,一个Fragment也可被多个Activity 复用.Fragment可以响应自己的输入事件,并拥有自己的生命周期,但它们的生命周期直接被其所属的 ...
- Android中Fragment生命周期和基本用法
1.基本概念 1. Fragment是什么? Fragment是可以让你的app纵享丝滑的设计,如果你的app想在现在基础上性能大幅度提高,并且占用内存降低,同样的界面Activity占用内存比Fra ...
随机推荐
- Laravel-错误调试与记录日志
Laravel-错误调试与记录日志 标签(空格分隔): php 错误调试 配置 修改/config/app.php 'debug' => env('APP_DEBUG', true), 开启de ...
- Kali linux 2016.2(Rolling)中metasploit的搜集特定网站的目录结构
不多说,直接上干货! parent directory site: testfire.net 至于这里怎么FQ,很简单,请见我下面的博客! kali 2.0安装 lantern(成功FQ) shado ...
- 【DNN 系列】 模块开发 8.0.1
1.创建第一个模块需要准备的东西有 https://github.com/dnnsoftware/DNN.Templates/releases/tag/1.0.1 VS 2015 插件 创建一个项目M ...
- KafkaProducer的整体逻辑
概述 KafkaProducer是用户向kafka servers发送消息的客户端.官网上对producer的记载如下: Kafka所有的节点都可以应答metadata的请求,这些metadata中包 ...
- RHEL启动错误:Kernel panic - not syncing:Attempted to kill init!解决方案
Virtual Box虚拟机启动RHEL系统报错,错误信息如下: 解决方案: 在GRUB引导界面按下e键,进入下图所示界面. 选择第二项,按下e键,进入编辑状态 在结尾追加enforcing=0,按下 ...
- 【转载】AngularJS 用$sce服务来过滤HTML标签,解决无法正确显示后台传递的html标签
angular js的强大之处之一就是他的数据双向绑定这一牛B功能,我们会常常用到的两个东西就是ng-bind和针对form的ng-model.但在我们的项目当中会遇到这样的情况,后台返回的数据中带有 ...
- c# 之抽象属性
抽象属性 属性可以使类.结构.接口的成员,自然也可以是抽象类的抽象属性了,抽象属性同抽象方法一样在派生类中被实现. using System; using System.Collections.Gen ...
- caioj 1618 【动态规划】矩阵相乘的次数
刷刷水题压压惊 低级版的能量项链 相当于复习一次中链式dp 这种合并了之后又后效性的题目 都可以用类似的方法做 #include<cstdio> #include<cstring&g ...
- linux学习之高并发服务器篇(二)
高并发服务器 1.线程池并发服务器 两种模型: 预先创建阻塞于accept多线程,使用互斥锁上锁保护accept(减少了每次创建线程的开销) 预先创建多线程,由主线程调用accept 线程池 3.多路 ...
- 基于Java的开源CMS系统选择
CMS概述 对于网站CMS系统而言,基于PHP的是主流,如Drupal/Joomla在各个主流虚拟机提供商上都是标准配置,也被广泛使用. 但如果你拥有Java团队,或者项目目标是想建立一个企业网使用的 ...