Reputation: 213
So i am trying to make a code which will change the color of the text in a textView I declared the color in the XML as this:
<color name="right">#FF00FF00</color>
However, when I try to change the color of the TextView score, in the following:
if(input.equalsIgnoreCase(answer+"")){
numRight++;
score.setTextColor(R.color.right);
correct="Correct!";
}
The text just dissapears. Am I referencing the color wrong? why doesnt this work?
Upvotes: 0
Views: 6278
Reputation: 1563
I hope it will work properly.
textView1.setTextColor(getResources().getColor(R.color.all));
all is name which is pertaining to color define in xml file like that.
<color name= "all">#ffffff</color>
you can use also below format it is working properly for me.
textView1.setTextColor(0xff000000);
Upvotes: 1
Reputation: 13856
You are referencing it incorrectly:
score.setTextColor(getResources().getColor(R.color.right);
Upvotes: 5