开发者

Including Android Activities (and their layouts) in JAR files

开发者 https://www.devze.com 2022-12-25 11:26 出处:网络
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 resour

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 an开发者_运维技巧yone know if this is possible? Any other ideas?


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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号