Reputation: 153
I tried this
txt.setTextColor(0xA4C639);
But then My Textview is invisible ... I also added one Color in values but I dont know how to use them programmaticly.
I DONT want to use this :
android:textColor="@color/droid_green"
I want to make it in my onCreate
Upvotes: 1
Views: 227
Reputation: 11776
USE
txt.setTextColor(Color.Black);//use any other color
P.S.
You can make new Color object as well or use Static
one as above
Example of making color object.
Color temp = new Color(R,B,G,A);//R,B,G are integer for Red, Blue, Green ranging from 0 to 255 and A is alpha
Or you can use HexCode as well as following:
Color temp = Color.decode("#FFCCEE");//Change to any other hexcode
And finally you can use the temp which is object of Color as follow:
txt.setTextColor(temp);
Upvotes: 4
Reputation: 441
you could also have used this.
txt.setTextColor(0xffA4C639);
An Android color is a 32-bit integer value consisting of four eight bit parts, ARGB. Here A stands for alpha which is 00 in your case so you find it invisible, FF will set alpha to 100 % and will make your text visible. Hope this helps :)
Upvotes: 1