TextView
의 글꼴을 LinearLayout
의 반복을 통해 반복하고 instanceof
을 사용하여 글꼴을 설정하려고합니다.안드로이드 instanceof 모든 위젯을 감지?
양식은 현재 4 TextView
'과 하나의 Button
으로 구성됩니다.
아래의 코드는 모두 View
s입니다. Button
도 TextView
입니까? 나는 각 뷰의 클래스 이름을 기록하면
/* Set fonts */
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_screenincourse_wrapper);
for (int i = 0; i < ll.getChildCount(); i++) {
View v = ll.getChildAt(i);
if (v instanceof TextView) {
((TextView) v).setTypeface(Fonts.get3dDumbFont(this));
}
}
IT는 텍스트 뷰를 반환하고 버튼 그래서 정확한 컨트롤이 포착되고있다 알고있다.
문제는 Button 및 TextView의 글꼴이 설정되고 있으며 TextView
의 글꼴 만 필요합니다.
나는 다음과 같은 일을하고 있지만 위의 코드가 예상대로 작동하지 않는 이유에 대해 흥미를 느끼고 있습니다.
/* Set fonts */
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_screenincourse_wrapper);
for (int i = 0; i < ll.getChildCount(); i++) {
View v = ll.getChildAt(i);
if (v.getClass().getName().contains("TextView")) {
((TextView) v).setTypeface(Fonts.get3dDumbFont(this));
}
}
Button과 TextView가 모두 View
유형입니까? 그렇다면이 작업을 수행하는 올바른 방법은 무엇입니까?
도움을 주시면 감사하겠습니다. 리키.
에크 TextView Class
확인을 확장 간단하다. 바보 나. 감사. – Ricky