LayoutInflater官方文档

来源:互联网 发布:免费搜狐会员软件 编辑:程序博客网 时间:2024/05/29 16:50

inflate

Added in API level 1
View inflate (XmlPullParser parser,                 ViewGroup root,                 boolean attachToRoot)

Inflate a new view hierarchy from the specified XML node. Throws InflateException if there is an error.

Important   For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime.

ParametersparserXmlPullParser: XML dom node containing the description of the view hierarchy.rootViewGroup: Optional view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)attachToRootboolean: Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.ReturnsViewThe root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file.
0 0