I want both my ViewA and ViewB to have the "title" tag. But I can't put this in attrs.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ViewA">
<attr name="title" format="string" />
</declare-styleable>
<declare-styleable name="ViewB">
<attr name="title" format="string" />
<attr name="max" format="integer" />
</declare-styleable>
</resources>
because of the error Attribute "title" has already been defined. Another question shows this solution:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="title" format="string" />
<declare-styleable name="ViewB">
<attr name="max" format="integer" />
</declare-styleable>
</resources>
but in that case, R.styleable.ViewA_title
and R.styleable.ViewB_title
are not generated. I need them for reading the attributes from the AttributeSet using the following code:
TypedArray a=getContext().obtainStyledAttributes( as, R.styleable.ViewA);
String title = a.getString(R.styleable.ViewA_title);
How can I solve this?