Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12401676
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: Android平台

2014-12-17 16:06:31

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

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

例如

  1. @Override  
  2.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
  3.         View rootView = inflater.inflate(R.layout.main,container,false);  
  4.         mLine1 = (TextView)rootView.findViewById(R.id.line1);  
  5.         mLine2 = (TextView)rootView.findViewById(R.id.line2);  
  6.         mDescription1 = (TextView)rootView.findViewById(R.id.line1_description);  
  7.         mDescription2 = (TextView)rootView.findViewById(R.id.line2_description);  
  8.         mVersion = (TextView)rootView.findViewById(R.id.version);  
  9.         mSignWifi = (TextView)rootView.findViewById(R.id.advice);  
  10.         mSignStreaming = (LinearLayout)rootView.findViewById(R.id.streaming);  
  11.         mSignInformation = (LinearLayout)rootView.findViewById(R.id.information);  
  12.         mPulseAnimation = AnimationUtils.loadAnimation(mApplication.getApplicationContext(), R.anim.pulse);  
  13.         mTextBitrate = (TextView)rootView.findViewById(R.id.bitrate);  
  14.         return rootView ;  
  15.     }  
  16.       

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

PS:
基本上,本座可以这么认为这两个东西类似于c#中的构造函数及Form_Load(),也许不严谨,但不重要!!

来自博客:
http://blog.csdn.net/loovejava/article/details/37765993
阅读(2844) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~