Android CheckedTextView如何获取choiceIndicator的默认drawable名称?
Android CheckedTextView how to get choiceIndicator default drawable name?
有人知道 Drawables
在 android.R.attr.listChoiceIndicatorMultiple
和 android.R.attr.listChoiceIndicatorSingle?
中使用的名称是什么
我想以编程方式在不使用原始资源可绘制模式之间切换。
无法使用这种方式:
view.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple);
所以我想找出 android.R.attr.listChoiceIndicatorMultiple
引用的真实 drawable 名称
我在 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);
有人知道 Drawables
在 android.R.attr.listChoiceIndicatorMultiple
和 android.R.attr.listChoiceIndicatorSingle?
我想以编程方式在不使用原始资源可绘制模式之间切换。
无法使用这种方式:
view.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple);
所以我想找出 android.R.attr.listChoiceIndicatorMultiple
我在 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);