views:

271

answers:

1

I have made an component for Android, which uses two drawables.

Using static values for the drawables in the code, the component works but now I want to declare the values in the properties (XML) does anyone know how to do this?

*Edit; Is there a way to do this without using the attrs.xml?

+1  A: 

You will need to set up a res/values/attrs.xml file to declare the attributes, then go through some code to retrieve those values inside of your View's constructor. I have a sample here that demonstrates the technique.

CommonsWare
Getting 404 on http://github.com/commonsguy/cw-advandroid/tree/master/Views/Meter/src/com/commonsware/android/
MrThys
Is there a way to do this in code? I don't have direct access to the R.styleable :-(
MrThys
Here is another sample: http://blog.pocketjourney.com/2008/05/02/android-tutorial-42-passing-custom-variables-via-xml-resource-files/
Mayra