一、Fragment静态创建生命周期
(1)Fragment contruct、onInflate、onCreate (2)Activity onCreate
com.csnt.fragment D/fun: StaticLoadFragment:contruct: 构造方法 com.csnt.fragment D/fun: StaticLoadFragment:onAttach: 当Fragment被加入到Activity中时调用,该方法中可获取到Fragment所在的Activity com.csnt.fragment D/fun: StaticLoadFragment:onCreate: 创建Fragment对象,此时Fragment不可见 com.csnt.fragment D/fun: StaticFragActivity:onCreate: Activity对象创建完成,但此时还不可见 com.csnt.fragment D/fun: StaticLoadFragment:onCreateView: 每次创建和绘制该Fragment的view组件时回调该方法,Fragment将会显示该方法返回的view组件 com.csnt.fragment D/fun: StaticLoadFragment:onViewCreated: 当Activity的onCreate方法执行完成后调用,所以在这个方法之前可能onCreate还没有执行完成,在此之前是没法经行交互的。该Fragment所在的View组件创建完毕 com.csnt.fragment D/fun: StaticLoadFragment:onActivityCreated: 当Activity的onCreate方法执行完成后回调该方法 com.csnt.fragment D/fun: StaticLoadFragment:onStart: 启动Fragment,此时Fragment可见 com.csnt.fragment D/fun: StaticFragActivity:onStart: Activity对象可见但无焦点 com.csnt.fragment D/fun: StaticFragActivity:onResume: Activity在屏幕可见并获取到焦点 com.csnt.fragment D/fun: StaticLoadFragment:onResume: fragment可见并获取焦点 com.csnt.fragment D/fun: StaticLoadFragment:onPause: fragment失去焦点但不可见 com.csnt.fragment D/fun: StaticFragActivity:onPause: Activity在屏幕可见但已失去焦点 com.csnt.fragment D/fun: StaticLoadFragment:onStop: fragment不可见但还在内存中 com.csnt.fragment D/fun: StaticFragActivity:onStop: Activity在屏幕不可见但还在内存中存在 com.csnt.fragment D/fun: StaticLoadFragment:onDestroyView: 销毁与fragment相关的视图但未与activity解绑 com.csnt.fragment D/fun: StaticLoadFragment:onDestroy: 销毁fragment com.csnt.fragment D/fun: StaticLoadFragment:onDetach: fragment与activity解绑 com.csnt.fragment D/fun: StaticFragActivity:onDestroy: Activity对象销毁
二、Fragment动态创建生命周期
(1)Activity onCreate (2)Fragment contruct、onCreate
com.csnt.fragment D/Dynamic: DynamicLoadActivity:onCreate: null com.csnt.fragment D/Dynamic: StaticLoadFragment:contruct: 构造方法 com.csnt.fragment D/Dynamic: StaticLoadFragment:onAttach: 当Fragment被加入到Activity中时调用,该方法中可获取到Fragment所在的Activity com.csnt.fragment D/Dynamic: StaticLoadFragment:onCreate: 创建Fragment对象,此时Fragment不可见 com.csnt.fragment D/Dynamic: StaticLoadFragment:onCreateView: 每次创建和绘制该Fragment的view组件时回调该方法,Fragment将会显示该方法返回的view组件 com.csnt.fragment D/Dynamic: StaticLoadFragment:onViewCreated: 当Activity的onCreate方法执行完成后调用,所以在这个方法之前可能onCreate还没有执行完成,在此之前是没法经行交互的。该Fragment所在的View组件创建完毕 com.csnt.fragment D/Dynamic: StaticLoadFragment:onActivityCreated: 当Activity的onCreate方法执行完成后回调该方法 com.csnt.fragment D/Dynamic: StaticLoadFragment:onStart: 启动Fragment,此时Fragment可见 com.csnt.fragment D/Dynamic: DynamicLoadActivity:onStart:? com.csnt.fragment D/Dynamic: DynamicLoadActivity:onResume:? com.csnt.fragment D/Dynamic: StaticLoadFragment:onResume: fragment可见并获取焦点 com.csnt.fragment D/Dynamic: StaticLoadFragment:onPause: fragment失去焦点但不可见 com.csnt.fragment D/Dynamic: StaticLoadFragment:onStop: fragment不可见但还在内存中 com.csnt.fragment D/Dynamic: StaticLoadFragment:onDestroyView: 销毁与fragment相关的视图但未与activity解绑 com.csnt.fragment D/Dynamic: StaticLoadFragment:onDestroy: 销毁fragment com.csnt.fragment D/Dynamic: StaticLoadFragment:onDetach: fragment与activity解绑 com.csnt.fragment D/Dynamic: DynamicLoadActivity:onPause:? com.csnt.fragment D/Dynamic: DynamicLoadActivity:onStop:? com.csnt.fragment D/Dynamic: DynamicLoadActivity:onDestroy:
|