Many people may have encountered this problem, that is, when you set the color of the button, the set color is invalid, black or other colors appear, and then many people use colorstatelist instead, the reason is that the parameter call is incorrect.
1st types: TV. setTextColor (android. graphics. Color. RED); // Color class that comes with the System
2nd types: TV. setTextColor (0xffff00ff); // 0xffffff00ff is int type data, grouped by 0x | ff | ff00ff, 0x indicates the color integer, ff indicates the transparency, and ff00ff indicates the color, note: Here, ffff00ff must be represented by 8 colors, and 6 colors such as ff00ff are not accepted.
3rd types: TV. setTextColor (this. getResources (). getColor (R. color. red); // you can set it by obtaining the resource file. R. color. red can also be R. string. red or R. drawable. red, of course, the premise is to make the corresponding configuration in the corresponding configuration file, such:
# FF0000
<Drawable name = "red"> # FF0000
<String name = "red"> # FF0000
Note that in the third method above, do not take the color you have defined as a parameter directly, for example:
TV. setTextColor (R. color. red); in this case, a color error occurs!
If you have any questions, please leave a message and repeat the source.