Reputation: 6202
I'm trying to specify a reference/resource-id to a drawable from a custom style.
If the drawable is an image file (ie, .png), everything is ok, however if the drawable is a xml layout file (ie, a selector), then I get the compile-time error:
No resource found that matches the given name (at 'net.monocross.app:button_drawable_id' with value '@layout/XmlSelector') ..\Resources\values\styles.xml
I'm trying to determine if this is an Android rule, or maybe a Monodroid issue, and if there are other means to this end ?
Thanks.
styles.xml
<style name ="DropdownButtonA">
<item name="android:layout_width">@dimen/button_width</item>
<item name="android:layout_height">@dimen/button_height</item>
<item name="net.monocross.app:button_label_text">hi</item>
<item name="net.monocross.app:button_label_color">#99ABCDEF</item>
<!-- OK -->
<item name="net.monocross.app:button_drawable_id">@drawable/PngImage</item>
<!-- ERROR -->
<item name="net.monocross.app:button_drawable_id">@drawable/XmlSelector</item>
</style>
attrs.xml
<declare-styleable name="DropdownButton">
<attr name="button_label_text" format="string"></attr>
<attr name="button_label_color" format="color"></attr>
<attr name="button_drawable_id" format="reference"></attr>
</declare-styleable>
Upvotes: 1
Views: 382
Reputation: 6202
I needed to rename the xml-drawable file
XmlSelector.axml -> xml_selector.xml
If that doesn't work for you, just try keeping the .axml extension.
Upvotes: 1