onCreate是指创建该fragment,类似于Activity.onCreate,你可以在其中初始化除了view之外的东西;

onCreateView是创建该fragment对应的视图,你必须在这里创建自己的视图并返回给调用者。

例如

@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.main,container,false);mLine1 = (TextView)rootView.findViewById(R.id.line1);mLine2 = (TextView)rootView.findViewById(R.id.line2);mDescription1 = (TextView)rootView.findViewById(R.id.line1_description);mDescription2 = (TextView)rootView.findViewById(R.id.line2_description);mVersion = (TextView)rootView.findViewById(R.id.version);mSignWifi = (TextView)rootView.findViewById(R.id.advice);mSignStreaming = (LinearLayout)rootView.findViewById(R.id.streaming);mSignInformation = (LinearLayout)rootView.findViewById(R.id.information);mPulseAnimation = AnimationUtils.loadAnimation(mApplication.getApplicationContext(), R.anim.pulse);mTextBitrate = (TextView)rootView.findViewById(R.id.bitrate);return rootView ;}

部分代码在 onCreateView中调用super.onCreateView。
其实有没有调用都无所谓,因为super.onCreateView是直接返回null的。

Fragment的onCreate和onCreateView区别相关推荐

  1. Fragment中OnCreate与OnCreateView区别

    在使用Java实现Android的时候,有时候使用的是OnCreate有时候使用OnCreateView. 区别: 1. Fragment中onCreate类似于Activity.onCreate,在 ...

  2. android onCreate与onCreateView的区别

    onCreate是指创建该fragment,类似于Activity.onCreate,你可以在其中初始化除了view之外的东西. onCreateView是创建该fragment对应的视图,你必须在这 ...

  3. onCreate与onStart区别,onStart与onResume区别

    http://www.cnblogs.com/kofi1122/archive/2011/04/10/2011772.html Activity生命周期之我见 关于Activity生命周期的文章很多, ...

  4. ViewPager刷新问题详解

    原文链接:简书diygreen,http://www.jianshu.com/p/266861496508 一.PagerAdapter介绍 先看效果图 PagerAdapter简介 ListView ...

  5. 片段中onCreate(),onCreateView()和onActivityCreated()的区别和用法

    本文翻译自:Difference and uses of onCreate(), onCreateView() and onActivityCreated() in fragments 片段中的onC ...

  6. 使用FragmentPagerAdapter和FragmentStatePagerAdapter时Fragment生命周期区别

    使用FragmentPagerAdapter时Fragment的生命周期 FragmentPagerAdapter 会保存在内存中保存Fragment的实例,当ViewPager中Fragment的数 ...

  7. Fragment的详细使用

    一直在用Fragment,但是没有系统的整理过,Google了一下相关文章,看到了几篇,将几篇还不错的文章重点整理了下,很多是直接Copy的,只为做个笔记,以后翻来看比较方便,建议大家看一下下面几篇, ...

  8. Fragment 复习一

    参考Android Fragment完全解析,关于碎片你所需知道的一切 Android Fragment 真正的完全解析(上) Android Fragment 真正的完全解析(下) ###简介 官方 ...

  9. Android Fragment 解析(上)

    自从Fragment出现,曾经有段时间,感觉大家谈什么都能跟Fragment谈上关系,做什么都要问下Fragment能实现不~~~哈哈,是不是有点过~~~ 本篇博客力求为大家说明Fragment如何产 ...

最新文章

  1. 10种JavaScript开发者必备的VS Code插件
  2. python频率_Python中的频率分析
  3. c++ 图的连通分量是什么_【自考】数据结构第五章图,期末不挂科指南,第9篇
  4. 网络IO模型详细分析
  5. NYOJ599 - 奋斗的小蜗牛
  6. 如何打出好看的数学公式呢?
  7. 获取synchronized锁中的阻塞队列中的线程是非公平的
  8. 微信机器人框架【Python】
  9. 算法导论 pdf_下载算法导论_高清_pdf
  10. word中设置文档的多级标题,如1,1.1,1.1.1等
  11. 【Allennlp】: 怎样创建Allennlp中的Configuration文件
  12. Electron 屏幕锁定 快捷键锁定 屏蔽快捷键
  13. python培训班靠谱吗-天津靠谱的python培训班
  14. 建立主DNS区域和辅助DNS区域的最佳实践
  15. python 判断两个列表间是否具有包含关系以及获取子列表在父列表中的索引
  16. 全球与中国汽车牛皮革市场“十四五”前景规划及运营趋势研究报告2022-2028年
  17. 如何求地球上两点之间的最短距离_初中数学求线段之和最小的问题,知识点题型汇总...
  18. NKOI 1349 工作安排
  19. 一点点的社会经济学和组织领导学
  20. 西门子s7-400闭环控制模块_西门子PLC模块CPU1517

热门文章

  1. pjsip学习 ------ 二
  2. kali linux查看版本,kali linux 系统版本的查看方法
  3. free pascal
  4. android淡入淡出动画循环,Android activity动画(淡入淡出)
  5. python开发中级_针对中级Python开发人员的13个项目构想
  6. JavaScript:通过点击按钮实现个人信息的录入,进而输出个人信息
  7. 检测浏览器是否接受Cookies(Downmoon)?
  8. 解决liquibase.exception.LockException: Could not acquire change log lock. Currently locked by XXXX
  9. NHWC BGR -> NCHW RGB
  10. QRJDC搭建实现QQ扫码登录对接青龙对接傻妞