2017-05-10 1 views
1

누군가가 내가 프로그래밍 방식처럼 원래 resouces 드로어 블을 unsing 모드를 전환 할 android.R.attr.listChoi‌​ceIndicatorMultipleandroid.R.attr.listChoi‌​ceIndicatorSingle?Android CheckedTextView choiceIndicator 기본 드로어 블 이름을 가져 오는 방법은 무엇입니까?

에 사용하여 이름 기본 Drawables 무엇인지 알고있다.

view.setCheckMarkDrawable(android.R.attr.listChoi‌​ceIndicatorMultiple); 

그래서 내가 APPCOMPAT 안에서 발견 한 android.R.attr.listChoi‌​ceIndicatorMultiple

+0

당신이 구글 검색에서 "안드로이드 받고 속성 값"resutls 같은 말인가요? – Selvin

+0

@Selvin, 런타임 사용 방법에 대해 알고 있습니까? 당신은 이미 그것과 비슷한 것을 시도합니까? 그래, 그래! 나는 질문을하기 전에 혼자서 연구했고 구성 요소의 기본 스타일을 검사 해 보았습니다. –

답변

1

다음 리소스에서 참조하는 실제 그릴 수 이름을 알아 내기 위해 노력하고있어 :

이 방법을 사용 할 수 없습니다

static int checkMaterial = android.support.v7.appcompat.R.drawable.abc_btn_check_material; 
    static int radioMaterial = android.support.v7.appcompat.R.drawable.abc_btn_radio_material; 

그리고 제대로 작동합니다.

편집

더 나은 솔루션 :

ViewHolder holder;... 

TypedValue value = new TypedValue(); 
Resources.Theme theme = holder.textView.getContext().getTheme(); 
int checkMarkDrawableResId; 

if (isMultiSelectionEnabled) { 

    theme.resolveAttribute(android.R.attr.listChoiceIndicatorMultiple, value, true); 
    int checkMarkDrawableResId = value.resourceId; 

} else { 

    theme.resolveAttribute(android.R.attr.listChoiceIndicatorSingle, value, true); 
    int checkMarkDrawableResId = value.resourceId; 
} 

holder.textView.setCheckMarkDrawable(checkMarkDrawableResId); 
관련 문제