什么是rootView? [英] What is a rootView?

查看:487
本文介绍了什么是rootView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我是Android新手,我已经使用默认模板主细节流程打开了一个项目,但我不知道什么是 rootView .我已经在developer.android.com上搜索了,但我不太了解...

Hello I'm new in Android and I've opened a project with the default template Master detail flow but I don't know what is a rootView. I've search on developer.android.com but I don't really understood it ...

因此,如果有人可以清楚地解释我的意思,这对我有很大帮助.

So if someone can explain me clearly what's this thing doing it would help me a lot.

谢谢!

有代码!

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments().containsKey(ARG_ITEM_ID)) {
        mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
    }
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);
    if (mItem != null) {
        mLinearLayout = (LinearLayout)findViewById(R.id.layout); 
    }
    return rootView;
}

推荐答案

RootView是放置所有其他视图的视图.就像树形结构的根节点一样,它是所有子级的父级.

RootView is the View in which all the other views are placed. It is like the root node in a tree structure which is the parent to all the children.

例如,您在布局中有多个Button,这些Button放置在LinearLayout内.然后,LinearLayout称为RootView,因为它在结构中的位置最高,并且所有内容都必须放置在其中.

For example, you have multiple Buttons in your layout which are placed inside a LinearLayout. Then LinearLayout is called the RootView as it would have the highest position in the structure and everything would have to be placed inside it.

希望这可以消除您的疑问.

Hope this clears your doubt.

这篇关于什么是rootView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆