Error:Error: Found item Attr/duration more than one time
阿新 • • 發佈:2018-11-02
在android 應用開發中,經常會使用自定義的屬性,例如:
<declare-styleable name="PERCHOOSER"> <attr name="title" format="string" /> <attr name="index" format="integer" /> </declare-styleable> <declare-styleable name="SIMULATION_PREFERENCE"> <attr name="title" format="string" /> <attr name="summary" format="string" /> <attr name="icon" format="reference" /> <attr name="stateIcon" format="reference" /> </declare-styleable>
兩組attrs 應該是用於兩個不同的佈局中,但是都定義了attr title:
<attr name="title" format="string" />
如果這樣會報出:
Error:Error: Found item Attr/duration more than one time
修改如下:
<attr name="title" format="string" /> <declare-styleable name="PERCHOOSER"> <attr name="title" /> <attr name="index" format="integer" /> </declare-styleable> <declare-styleable name="SIMULATION_PREFERENCE"> <attr name="title" /> <attr name="summary" format="string" /> <attr name="icon" format="reference" /> <attr name="stateIcon" format="reference" /> </declare-styleable>
對於同一個package,這裡attr 只需要定義一次,使用的時候宣告即可。