包括Android活动(及其布局)的JAR文件布局、文件、Android、JAR

由网友(校长,借个火)分享简介:我想写可以共享一个JAR文件的库。该库将包括一个活动,我想包括在JAR的布局。因为它似乎并不可能包括在一个JAR资源文件,我不希望最终用户必须包括这些文件本身我想这将是一个不错的黑客包括XML作为一个字符串然后手动充气它。有谁知道这是否可能?任何其他的想法?I'm trying to write a library...

我想写可以共享一个JAR文件的库。该库将包括一个活动,我想包括在JAR的布局。因为它似乎并不可能包括在一个JAR资源文件,我不希望最终用户必须包括这些文件本身我想这将是一个不错的黑客包括XML作为一个字符串然后手动充气它。有谁知道这是否可能?任何其他的想法?

I'm trying to write a library that can be shared as a JAR file. This library will include an Activity and I'd like to include the layout in the JAR. Since it doesn't seem possible to include resource files in a JAR and I don't want the end-users to have to include these files themselves I was thinking it would be a nice hack to include the XML as a String then manually inflate it. Does anyone know if this is possible? Any other ideas?

推荐答案

本机布局的XML文件转换为二进制形式,包括烤在构建时资源ID。

Native layout XML files are converted to a binary form, and include resource IDs baked at build time.

不过,由于所有的GUI元素可以在运行时被实例化,你很可能推出自己的吹气与XML解析器和一点反思。

However since all GUI elements can be instantiated at runtime, you could probably roll your own inflater with an XML parser and a bit of reflection.

这可能是更容易在你的情况下,只是以编程方式构建活动视图。

It may be easier in your case just to build the activity view programatically.

阅读全文

相关推荐

最新文章