2010-12-31 5 views
30

모든 편집 가능한 요소에 대해 Tag라는 사용자 정의 속성을 생성하려고합니다. 나는 내가 글고 치기 위해 "속성 태그가 이미 정의되었습니다"라는 오류가Android의 사용자 정의 속성

<declare-styleable name="Spinner"> 
    <attr name="tag" format="string" /> 
</declare-styleable> 

<declare-styleable name="EditText"> 
    <attr name="tag" format="string" /> 
</declare-styleable> 

을 attrs.xml이 다음을 추가했다. 다른 요소에 같은 이름의 사용자 지정 특성을 만들 수 있습니까?

답변

70

당신은 둘 이상의 위치에 ATTR을 사용하여 다음과 같은 것이 같은 <resources> 요소 내부 루트 요소에 넣어하려는 경우 :

<resources> 

    <attr name="tag" format="string" /> 

    <declare-styleable name="Spinner"> 
     <attr name="tag" /> 
    </declare-styleable> 

    <declare-styleable name="EditText"> 
     <attr name="tag" /> 
    </declare-styleable> 

</resources> 

지금 당신은 어디서든 당신이 원하는에 태그 속성을 사용할 수 있습니다 이 xml 파일 안에.

희망은 도움이됩니다.

관련 문제