2012-03-16 7 views
1

파일에 일부 속성을 추가했습니다. attr.xml. 여기에 해당 코드 :Android : 경우에 따라 스타일을 인식하지 못함

<?xml version="1.0" encoding="utf-8"?> 
<resources> 

    <declare-styleable name="gallery_view"> 
     <attr name="android:galleryItemBackground"/> 
    </declare-styleable> 

    <declare-styleable name="Dot"> 
     <attr name="color" format="color"/> 
     <attr name="radius" format="dimension"/> 
    </declare-styleable> 

</resources> 

하지만하지 않는 이유를 사용할 때 :

R.styleable.gallery_view_android_galleryItemBackground : 오류없이.

R.styleable.Dot_color은 R 파일에서이 필드를 볼 수 없기 때문에 오류가 발생합니다.

도와주세요.

감사합니다 :)

+1

** android.R.styleable 클래스와 그 필드는 공개 API **에서 제거하고,이 옵션을 선택합니다 : http://stackoverflow.com/questions/6675403/r -styleable-can-be-resolved-why/6675824 # 6675824 –

+2

미안하지만, 첫 번째 경우에는 여전히 사용할 수 있습니다. 날 설명해 줘. 고마워요 :) – hqt

답변

0
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Dot); 
a.getColor.... 
+2

더 설명해 주시겠습니까? 하지만'R.styleable.DOT'을 얻으려고 할 때 여전히 같은 오류가 발생합니다 – hqt

+0

http://developer.android.com/reference/android/content/res/Resources.Theme.html#obtainStyledAttributes(int, int [ ]) –

관련 문제