[mono-android] Load resources on a custom library

Amir Waldman amirw2k at gmail.com
Thu Mar 17 09:48:24 EDT 2011


Update:

I can confirm that loading a resource ID (stored in the main assembly), by a
code located in a class library works.

Now there's the hassle of passing all the ID's manually to the class
library. 

 

The problem is resource ID's are stored as constants in
Resource.Designer.cs. 

 

Until there's full support for resources in class libraries, it will be
helpful if they can be accessed dynamically with a dictionary collection:
Dictionary<string, int>.

For example:

 

Resource.Layout.Layouts["my_layout"];

Resource.Drawable.Drawables["my_drawable"];

Resource.String.Strings["my_string"];

Resource.String.Strings["my_string"];

 

This way one can access resources by name anywhere in a project, including a
class library. Should be easy to implement in a code generator, when the
alternative is reflection that I'd rather avoid.

 

 

Thanks,

Amir

 

 

From: Amir Waldman [mailto:amirw2k at gmail.com] 
Sent: Thursday, March 17, 2011 3:01 PM
To: 'monodroid at lists.ximian.com'
Subject: Load resources on a custom library

 

Is there any way to load resources on a class library? 

I was able to create manually most layouts and graphics using code, but
advanced layout features and shapes are better defined by XML.

 

The best option for me (which monodroid doesn't support) is to store
resources within the class library, so you can share it among different
projects.

 

Thanks,

Amir

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110317/cd2e4ad1/attachment-0001.html 


More information about the Monodroid mailing list