Fragment的onCreate和onCreateView的区别

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 08:06:40

Fragment的onCreate和onCreateView的区别
Fragment的onCreate和onCreateView的区别

Fragment的onCreate和onCreateView的区别
onCreate是指创建该fragment,类似于Activity.onCreate,你可以在其中初始化除了view之外的东西;
onCreateView是创建该fragment对应的视图,你必须在这里创建自己的视图并返回给调用者.
例如
[java] view plaincopyprint?
@Override
public 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的区别 Fragment的onCreate和onCreateView的区别 Fragment的onCreate和onCreateView的区别 CMainFrame 里的oncreate函数有什么作用和view里的oncreate函数有什么作用 fragment中的onCreateView和onViewCreated的区别和联系 fragment和fragmentation有什么区别? tabhost和fragment有什么区别 android tabhost和fragment哪个效率高 MFC的消息处理函数(例如:OnCreate)和消息过程函数(例如:WindowProc)的区别?并不是说OnCreate和WindowProc的区别,只是分别举个消息映射函数和窗口过程函数的例子.MFC的消息处理函数和消息过 谁能详细解释下fragment,choppy,comma splice,run on以及他们的区别?stylistic problems!如果可以的话,最好有用些例句说明一下. 英语改错:identify stylistic problem~ 请问run on、comma splice、fragment、choppy分别指的是什么错误可否举例说明,可追加分数~ 把下面的英语句子改成正确的 关于run-on 和 fragment 的知识点 如果没涉及到也请改正 谢谢I felt scared and be careful to everyting because this was my first time to stay with mant students who different races from me for a android fragment相关问题主界面由两个fragment构成,现在我想左边的fragment从左边移除屏幕,右边的fragment同时填充满整个屏幕需要怎么做, oncreate函数是哪种语言 android 跳转到fragmentandroid开发中,如何从外部其他的activity类中跳转到fragment中指定的fragment碎片中呢? 为什么是clay fragment,和clay pipes呢,.RT.干吗要加个CLAY? scrap,chip,fraction,shatter,fragment都有碎片的意思,有何区别? fragment offset是什么意思