Ich möchte, dass sowohl ViewA als auch ViewB den Titel "title" haben. Aber ich kann das nicht in attrs.xml
setzen:Wie deklarieren Sie mehrere Attribute mit demselben Namen für verschiedene Tags?
<?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>
aufgrund des Fehlers Attribut „Titel“ ist bereits definiert. Another question zeigt diese Lösung:
<?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>
aber in diesem Fall R.styleable.ViewA_title
und R.styleable.ViewB_title
werden nicht erzeugt. Ich brauche sie zum Lesen der Attribute aus dem AttributSet mit dem folgenden Code:
Wie kann ich das lösen?
Ähnlich wie http://stackoverflow.com/questions/4434327/same-named-attributes-in-attrs-xml-for-custom-view – Suragch