In the ApiDemos, there is a view example called Gallery1 which declares a custom style in attrs.xml, as such:
<declare-styleable name="Gallery1">
<attr name="android:galleryItemBackground" />
</declare-styleable>
now, I want to do the same thing for my widgets, but using a different namespace. However, as soon as I replace the android: namespace with something else, I get this error:
ERROR: In Gallery1, unable to find attribute myns:galleryItemBackground
Unable to find attribute? Why does it look for an attribute I am about to declare? Isn't the point of this file to be able to name your own custom attributes?
It's interesting to note that it works if you do not supply a custom namespace, but just an attribute name.
I had a similar problem resulting in the error message No resource identifier found for attribute in package
The solution for me was to declare the namespace when you use the custom attribute.
In your xml file where you use your custom attribute specify:
xmlns:myns="http://schemas.android.com/apk/res-auto"
...
<gallery.widget.package.Gallery1
myns:myCustomAttr="xxx"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With