[mono-android] Getting the xml file for a view resoruce

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Wed Nov 30 23:56:58 EST 2011


Our XmlReader-based mapping will be available *after* the next release.

Though there are things to note; we cannot provide features that Android 
does not provide. For example, I noticed that GetLayout() returns an 
XmlResourceParser implementation that does not support lots of namespace 
processing methods (getPrefix(), getAttributePrefix(), getNamespace(int) 
etc.), while getFeature() with relevant flag returns true (funny? yep).

I hope this will help in the (near) future.

Atsushi Eno

> 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
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>



More information about the Monodroid mailing list