You have to use getColorStateList()
I was also struggling with this problem, if you want to use a state list
, you need to declared it in the color
resources folder, instead of the drawable
folder, and use the setTextColor(getResources().getColorStateList(R.color.your_colors))
.