Skip to content Skip to sidebar Skip to footer

Custom Attributes In Android

I'm trying to create a custom attribute called Tag for all editable elements. I added the following to attrs.xml

Solution 1:

If you are going to use an attr in more than one place then put it in the root element inside the <resources> element like the following :

<resources><attrname="tag"format="string" /><declare-styleablename="Spinner"><attrname="tag" /></declare-styleable><declare-styleablename="EditText"><attrname="tag" /></declare-styleable></resources>

Now you can use the tag attribute in anywhere you want inside this xml file .

Hope That Helps.

Solution 2:

See if my detailed answer about custom attributes helps: Defining custom attrs

Post a Comment for "Custom Attributes In Android"