LayoutInflater的用法

Posted OYP

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LayoutInflater的用法相关的知识,希望对你有一定的参考价值。

Instantiates a layout XML file into its corresponding View objects. It is never used directly. Instead, use getLayoutInflater() or getSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context and correctly configured for the device you are running on. For example
LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
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; it only works with an XmlPullParser returned from a compiled resource (R.something file.)

以上是关于LayoutInflater的用法的主要内容,如果未能解决你的问题,请参考以下文章

Android - LayoutInflater和inflate方法的用法

android LayoutInflatersetContentViewfindviewbyid 区分解析

Android LayoutInflater开发中的用法

真的知道LayoutInflater的正确用法么?

真的知道LayoutInflater的正确用法么?

关于LayoutInflater的错误用法(警告提示:Avoid passing null as the view root)