我正在尝试使用 ColorStateList
更改 RadioGroup
的颜色,但遇到了一些基本错误。我可以在不使用 ColorStateList
的情况下更改 RadioGroup
按钮的颜色吗?有没有更简单的方法?
我已经导入了以下内容,但仍然出现“无法解析符号”。
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
我正在尝试在下面实现 ColorStateList
,不确定我是否做对了,但首先我需要修复“无法解析符号错误”:
if (Item.getCar()=='Audi'){
ColorStateList csl = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_enabled}, //disabled
new int[]{android.R.attr.state_enabled} //enabled
},
new int[] {
Color.BLACK //disabled
,Color.BLUE //enabled
}
);
int textColor = Color.parseColor("#000000");
x.radioGroup.set(ColorStateList.valueOf(textColor));
对于试图让 ColorStateList
工作的任何帮助,我们表示赞赏。
最佳答案
您需要导入以下内容
import android.content.res.ColorStateList;
import android.graphics.Color;
它对我有用。
关于android - 无法解析符号 ColorStateList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37872847/