[Simple-support] Android compiled XML resources
Brought to you by:
niallg
|
From: Alec P. <al...@et...> - 2011-05-01 01:10:29
|
I would like to use the simple framework to instantiate objects from compiled xml resources (from the /res/xml directory) in an Android app. I've explored this a little bit, and here are the issues I've come across so far: 1) I need to start the framework using an existing XmlPullParser (obtained from Resources.getXml()). I can't do that when PullReader has default visibility and NodeBuilder.read(EventReader) is private. (I got past this by forking the framework code). 2) XmlResourceParser (the concrete class that you get from Resources.getXml()) throws an exception when you call getNamespace() and getAttributeNamespace(). (I got past this by changing PullReader not to call those methods.) 3) The values returned are the raw string values provided. What I'd like to retrieve are the referenced resources (so instead of "@string/some_string" I would like the value to be "some string value"). I stopped here to see if anybody else has looked into the problem. I suspect that the right way to do this is to write a class implementing the InputNode interface to wrap around XmlResourceParser. This may not be faster than using a "raw" xml file, but I would like to leverage the resource localization of the Android framework. |