问题描述
我使用的代码不是我的工作中的代码.此代码使用CheckedTextView,请执行以下操作:
I'm using a code that is not mine in my work.This code uses CheckedTextView, do this:
...
AlertDialog.Builder alert;
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
switch (soundPreference.getType()) {
case BOOLEAN:
CheckedTextView checkedTextView = (CheckedTextView) v;
boolean checked = !checkedTextView.isChecked();
((CheckedTextView) v).setChecked(checked);
switch (soundPreference.getKey()) {
case SOUND_ACTIVE:
sound.setAlarmActive(checked);
break;
...
可以正常工作,问题是我希望更改复选框图形.现在看起来像(我想是defualt):
works perfectly, the problem is that I want I want to change the checkbox graphic.Right now it looks like (defualt, I think):
我想得到这样的东西:
如果CheckedTextView是在xml中定义的,则知道该怎么做.我的问题不在xml中定义,不知道该怎么办.
if the CheckedTextView were defined in xml, know how to do it.My problem is not being defined in xml, do not know how to do it.
我发现了这一点:为ListView定制CheckedTextView 但我不知道如何实现
I found this:Customize the CheckedTextView for ListViewbut I do not know how to implement it
感谢任何帮助.
非常感谢您
推荐答案
示例:
myCheckedTextView.setCheckMarkDrawable(R.drawable.icon);
此方法使您可以动态设置复选标记图像.设置CheckedTextView
时应调用它.开发人员参考中的方法仅需要您要使用的图像资源的ID.
This method allows you to set the check mark image dynamically. You should call it when setting up the CheckedTextView
.The method in the developer reference just needs the id of the image resource you want to use.
还有一个版本,它使用Drawable
作为参数而不是id.
There is also a version that takes a Drawable
as a parameter instead of an id.
这篇关于在Android中自定义CheckedTextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!