Я хочу, чтобы мой ViewA и ViewB имели тег title. Но я не могу поместить это в 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>
из-за ошибки Атрибут title уже определен. Другой вопрос показывает это решение:
<?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>
но в этом случае R.styleable.ViewA_title
и R.styleable.ViewB_title
не генерируются. Они нужны мне для чтения атрибутов из AttributeSet с использованием следующего кода:
TypedArray a=getContext().obtainStyledAttributes( as, R.styleable.ViewA);
String title = a.getString(R.styleable.ViewA_title);
Как я могу это решить?