自定义XML文件查看 [英] Custom xml file to view

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

问题描述

在我问这个问题,让我画画。

Before I ask the question, allow me to paint a picture.

说(不管什么原因,你看中),而不是把你的XML布局中的典型RES /布局文件夹中,我们反而把它在res /资产的文件夹。这可以以任何理由可言,但你这样做。

Say (for whatever reason you fancy) that instead of putting your xml layout in the typical res/layouts folder, we instead put it in the res/assets folder. This can be for any reason at all, but you are doing this.

你怎么会那么去膨胀的XML文件的视图。你不能简单地调用View.inflate(背景下,r.assets.yourview,假的),因为当编译器生成您的应用程序,它不会给R.值的资产文件夹。想想你自己的小空间做你想要的。

How would you then go about inflating that xml file to a view. You cant simply call View.inflate(context, r.assets.yourview, false) because when the compiler builds your app, it does not assign R. values to the assets folder. Consider it your own little space to do what you want with.

这里的问题是,你怎么去得到一个XML文件到一个视图。或者,也许,如何做LayoutInflater或View.Inflate(使用LayoutInflater)去制作一个视图从XML文件?

The question here is, how do you go about getting an xml file into a view. Or maybe, how does LayoutInflater or View.Inflate (which uses LayoutInflater) go about making a view from an xml file?

推荐答案

如果我理解正确的话,你要动态加载XML提交? (从.xml文件)

If I understood you correctly, you want to dynamically load XML submission? (from .xml file)

你为什么不使用LayoutInflater.inflate(XmlPullParser解析器的ViewGroup根)

Why do not you use LayoutInflater.inflate(XmlPullParser parser, ViewGroup root)

http://developer.android.com/reference/android/view/ LayoutInflater.html

这篇关于自定义XML文件查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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