[mono-android] Getting the xml file for a view resoruce
Jonathan Pryor
jonp at xamarin.com
Sun Nov 27 12:53:11 EST 2011
On Nov 26, 2011, at 10:06 PM, quan wrote:
> The problem is the following:
>
> Reading the AXML file of the view that is saved in the resources/layout folder.
The solution is a question: do you need to embed it as an AndroidResource? If not, embed it as a normal resource, and use System.Reflection.Assembly.GetManifestResourceStream() to read the XML. If you do, you may be able to edit the .csproj and add a <Resource/> element so that the file is embedded as a Resource in addition to being built as an AndroidResource (though I have no idea if this will actually work or confuse the IDE or...).
As for why the GetLayout(int)/GetXml(int)/etc. methods are missing, it's because we're aiming to reduce classlib duplication, and nuked the Java XML APIs from our binding, which caused these methods to also be hidden. We intend to provide an XmlReader-based mapping in the future to expose these methods, but haven't gotten there yet. In the meantime, if you really want/need to invoke these methods, you need to use Android.Runtime.JNIEnv and use the JNI infrastructure to invoke the Java method.
Finally, as for why using OpenRawResource() failed, it's because Android "compiles" XML into an internal binary format (presumably to speed up reading/parsing), and it's this binary format that you're reading. I have no idea what the format is, and (obviously) it's convertible into XML, but I have no idea how to do so...
- Jon
More information about the Monodroid
mailing list