回顾知识,发现问题!

看了很多网上关于fragment的讲解教程,发现很多都少了onViewStateRestored()这个周期,在此补充。

参考:http://www.android-doc.com/reference/android/app/Fragment.html#Lifecycle,做如下翻译,不足忘回馈。

onAttach(Activity) :    called once the fragment is associated with its activity.    调用该方法,将fragment与activity相关联onCreate(Bundle) :    called to do initial creation of the fragment.    调用该方法,将fragment初始化;onCreateView(LayoutInflater, ViewGroup, Bundle) :    creates and returns the view hierarchy associated with the fragment.    调用该方法,创建视图,返回结果View;onActivityCreated(Bundle):    tells the fragment that its activity has completed its own Activity.onCreate().    调用该方法,通知fragment,activity中的oncreate()方法已完成;onViewStateRestored(Bundle):    tells the fragment that all of the saved state of its view hierarchy has been restored.      调用该方法,通知fragment,该视图层已保存;onStart():    makes the fragment visible to the user (based on its containing activity being started).    调用该方法,和activity的started方法相关联,将fragment展示给用户;onResume():    makes the fragment interacting with the user (based on its containing activity being resumed).     调用该方法,和activity的resumed方法相关联,使fragment与用户交互;As a fragment is no longer being used, it goes through a reverse series of callbacks:调用以下的方法,fragment将不再被使用;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的paused方法被调用,或者fragment正在被activity修改;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的stopped方法被调用,或者fragment正在被activity修改;onDestroyView():    allows the fragment to clean up resources associated with its View.    调用该方法,fragment清除掉资源与该activity的关联;onDestroy() :    called to do final cleanup of the fragment's state.    调用该方法,清除fragment的状态;onDetach():    called immediately prior to the fragment no longer being associated with its activity.     调用该方法,清除fragment与该activity的关联;

更多相关文章

  1. Android EditText默认不弹出输入法的实现方法
  2. activity中onSaveInstanceState方法调用时机详解
  3. Android 利用getIdentifier()方法获取资源ID
  4. Android cursor query方法详解
  5. [置顶] Android系统安全之旅 第1章 编译Android程序的方法
  6. Android使背景灯(Brightness)高亮的方法
  7. android spinner自动弹出列表,设置title,TtextView不换行自动截取

随机推荐

  1. Selector的用法
  2. 秒懂Android开发之MotionLayout简单上手
  3. android学习笔记22:可展开的ListView
  4. android 五大应用开发框架是什么
  5. Android(安卓)Studio IDE 所遇问题汇总
  6. Android用户输入自动提示控件AutoComplet
  7. TelephonyManager类:Android手机及Sim卡状
  8. Android(安卓)屏幕截图并用WindowManager
  9. 友盟多渠道获取渠道名 附赠多渠道打包文
  10. Bugly Android自动上传符号表