zoukankan      html  css  js  c++  java
  • Fragment的生命周期(与Activity的对比)

    Fragment必须是依存与Activity而存在的,因此Activity的生命周期会直接影响到Fragment的生命周期。官网这张图很好的说明了两者生命周期的关系:

    可以看到Fragment比Activity多了几个额外的生命周期回调方法:
    onAttach(Activity)
    当Fragment与Activity发生关联时调用。
    onCreateView(LayoutInflater, ViewGroup,Bundle)
    创建该Fragment的视图
    onActivityCreated(Bundle)
    当Activity的onCreate方法返回时调用
    onDestoryView()
    与onCreateView想对应,当该Fragment的视图被移除时调用
    onDetach()
    与onAttach相对应,当Fragment与Activity关联被取消时调用
    注意:除了onCreateView,其他的所有方法如果你重写了,必须调用父类对于该方法的实现,

  • 相关阅读:
    codeforces round #433 div2
    bzoj1951
    bzoj3620
    bzoj2286
    bzoj1513
    bzoj4390
    codeforces round 430 div 2
    bzoj3339
    准备实现体积蒙皮
    看牛顿法的改进与验证局部收敛
  • 原文地址:https://www.cnblogs.com/changyaohua/p/4834140.html
Copyright © 2011-2022 走看看