Android ViewPagerIndicator 상세 설명 및 인 스 턴 스 코드
2349 단어 AndroidViewPagerIndicator
사용자 정의 View 속성 에 대한 단편 지식
사용자 정의 View 와 사용자 정의 속성 에 대한 지식 은 더 이상 언급 되 지 않 습 니 다.여기 서 다시 말 하 는 것 은 속성 이 사용자 정의 View 에서 가 져 오 는 방식 입 니 다.사용자 정의 속성 은 다음 과 같 습 니 다.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Wisely">
<attr name="wisely_1" format="boolean" />
<attr name="wisely_2" format="boolean" />
<attr name="wisely_3" format="boolean" />
<attr name="wisely_4" format="boolean" />
</declare-styleable>
<attr name="wisely_out" format="boolean" />
</resources>
사용자 정의 View 관련 코드 는 다음 과 같 습 니 다.
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Wisely);
typedArray.getBoolean(R.styleable.Wisely_wisely_1, true);
typedArray.recycle();
}
R.stylable.Wisely 를 중점적으로 보 세 요.R.stylable.Wisely 는 하나의 배열 로 돌아 갑 니 다.R.stylable.Wiselywisely_1 은 배열 의 색인 을 나타 내 는데 R 파일 에서 다음 과 같이 표시 합 니 다.
public static final class attr {
public static final int wisely_1 = 0x7f010000;
public static final int wisely_2 = 0x7f010001;
public static final int wisely_3 = 0x7f010002;
public static final int wisely_4 = 0x7f010003;
public static final int wisely_out = 0x7f010004;
}
public static final class styleable {
public static final int[] Wisely = { 0x7f010000, 0x7f010001,
0x7f010002, 0x7f010003 };
public static final int Wisely_wisely_1 = 0;
public static final int Wisely_wisely_2 = 1;
public static final int Wisely_wisely_3 = 2;
public static final int Wisely_wisely_4 = 3;
}
위 에서 한 가 지 를 볼 수 있 습 니 다.wiselyout 도 attrs.xml 의 속성 이지 만 Wisely 이름 을 가 진 태그 외 에 쓰 여 있 기 때문에 stylable 류 의 Wisely 배열 에 들 어가 지 않 았 습 니 다.읽 어 주 셔 서 감사합니다. 여러분 에 게 도움 이 되 기 를 바 랍 니 다.본 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!