网上有的博客写得太乱

不如自己翻译官方文档

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()

最新文章

  1. linux共享windows文件并自动化改变文件编码
  2. mysql无法登录
  3. BI之SSAS完整实战教程7 -- 设计维度、细化维度中 :浏览维度,细化维度
  4. SQL日期(转)
  5. Android UI--自定义ListView(实现下拉刷新+加载更多)
  6. MSDN 杂志:UI 前沿技术 - WPF 中的多点触控操作事件
  7. JavaScript(一)js简单介绍
  8. FPGA上如何求32个输入的最大值和次大值:分治
  9. 简单谈谈js中Promise的用法
  10. R数据分析 第一篇:温习概率论
  11. ●POJ 1509 Glass Beads
  12. Gitee(码云)、Github同时配置ssh key
  13. dom4j 通过 org.dom4j.XPath 设置命名空间来支持 带namespace 的 xpath
  14. Rsync同步设置的一例
  15. 利用RNN(lstm)生成文本【转】
  16. 『PyTorch』第十四弹_torch.nn.Module类属性
  17. Implementing the On Item Checked Event for the TListView Control
  18. 【[SDOI2011]拦截导弹】
  19. TensorFlow简要教程及线性回归算法示例
  20. halcon安装提示could not write updated path to HKLM

热门文章

  1. Everedit软件下载、安装和运行(免注册)
  2. 【AngularJS学习笔记】AngularJS表单验证
  3. bzoj3252: 攻略 优先队列 并查集 贪心
  4. nginx的Rewrite重写
  5. 负载均衡集群总结(Haproxy)
  6. opencv3.4.1和vs2017配置
  7. 关于memset赋最值
  8. CMSIS-RTOS 时间管理之时间延迟Time Delay
  9. zend framework获取数据库中枚举类enum的数据并将其转换成数组
  10. Intellij Idea创建的第一个JavaWeb程序