Android CheckedTextView如何获取choiceIndicator默认可绘制名称?
有人知道在Android CheckedTextView如何获取choiceIndicator默认可绘制名称?,android,android-view,android-resources,Android,Android View,Android Resources,有人知道在android.R.attr.listcoi中使用的默认Drawables名称是什么CEINDICATOR多个和android.R.attr.listcoiCEINDICATOR单字符? 我想有计划地在模式之间切换,不使用原始资源 使用这种方式是不可能的: view.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple); 因此,我试图找出android.R.attr.listcoi引用的真正的可绘
android.R.attr.listcoi中使用的默认Drawables
名称是什么CEINDICATOR多个
和android.R.attr.listcoiCEINDICATOR单字符?
我想有计划地在模式之间切换,不使用原始资源
使用这种方式是不可能的:
view.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple);
因此,我试图找出
android.R.attr.listcoi引用的真正的可绘制的名称CeIndicator Multiple
我在appCompat中找到了以下资源:
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);
你的意思是谷歌搜索中的“android获取属性值”结果?@Selvin,你知道如何使用运行时属性吗?你已经试过这样做了吗?所以,是的!在提出问题之前,我自己进行了研究,我尝试检查了组件defaultstyleable等等。