android - 我可以从未编译的 android XML 中扩充 android Activity 吗?

标签 android runtime inflate

我想知道是否可以在运行时从未编译的 Android XML 布局文件中扩充 Android Activity ?

最佳答案

API 中没有内置任何内容可以让您执行此操作。 Inflater 需要一个拉解析器来处理已编译的 XML 文件。作为通货膨胀处理的一部分,系统会处理很多事情,例如资源绑定(bind)。来自 the documentation for LayoutInflater :

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.)

我想您可以构建自己的 XML 处理程序并自己完成,但这需要大量工作。

关于android - 我可以从未编译的 android XML 中扩充 android Activity 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13080695/

相关文章:

android - RelativeLayout 和 ViewStub 膨胀

android - 使用凭据从 Android App 调用 Google Endpoint 时没有任何反应

python - 具有 10 个变量的 Scipy 差分进化需要多次迭代

C++ zilib deflate/inflate 和 ztream 参数

Python: "in"与正则表达式的速度

python - 难以理解函数的运行时复杂性

android - 从内存中扩充 XML 文件

android - 在 ViewPager 中输入动画

java - getJSONObject 在 android 4.3 下抛出 JSONException 但在 android 4.4.2 上工作正常

android - 在 Dialog 中添加 Adwhirl 导致 Inflate Exception