Android:片段:setContentView替代 [英] Android: Fragments: setContentView alternative
本文介绍了Android:片段:setContentView替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 fragments
重写现有项目,以将我的应用程序移植到平板电脑上.
I'm trying to rewrite an existing project using fragments
to port my application on tablet.
我正在用片段
替换活动.
问题是我不知道什么与 setContentView
方法等效?除了重写 onCreateView
之外,还有什么方法可以创建 Fragment的
视图?
The problem is that I don't know what is the equivalent to setContentView
method? Is there any way to create Fragment's
view except rewriting onCreateView
?
推荐答案
在 onCreateView()
方法中,您可以按以下方式返回片段的视图:
In the onCreateView()
method you can return the view of your fragment as follows :
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.ads_tab, container, false);
}
这篇关于Android:片段:setContentView替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文