2

Say I have

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText2"
        android:text="Save" />

At some point I might need to add some custom attributes, like this

<Button
            ...................................
            my-attribute = "value"
            ...................................
            android:text="Save" />

I tried to do this just like that but I get some errors, of course. I come from html5 world..

Is there a naming convention or something ?

Is there another (correct) way of doing this?

Michael
  • 4,376
  • 10
  • 42
  • 66
  • 3
    Have you read: [Declaring a custom android UI element using XML](http://stackoverflow.com/q/2695646/1267661)? – Sam Dec 26 '12 at 19:50
  • No, I missed that. Maybe because I searched for attributes. Anyway, that is a great resource! Thank you! – Michael Dec 26 '12 at 19:52
  • BTW, I don't think you can retrieve arbitrary attributes for built in Views (e.g. Button), but you can definitely add custom attributes for your custom view. – dmon Dec 26 '12 at 22:44

0 Answers0