views:

61

answers:

2

I am creating the custom textview i want to give black textcolor to this textview. how can i set textcolor. my code is

TextView textview = new TextView(this);

textview.setText("Please follow this Description");

setContentView(_textview);

when i use textview.setTextColor(Integer.parseInt("#000000"))

Thanks in advance

A: 

I found the solution it is done by using the code

textview.setTextColor(Color.BLACK);

Amit Thaper
+2  A: 

Use Color.parseColor():

textview.setTextColor(Color.parseColor("#000000"));

another option is to use HEX integer directly:

textview.setTextColor(0xff000000);
Konstantin Burov
The code allows you to set not only predefined colors, but any color in formats of #RRGGBB or #AARRGGBB
Konstantin Burov
yes its really great answer Thanks
Amit Thaper
According to this answer how can i set my text to bold.
Amit Thaper
Thanks Konstantin Burov Its Really help me
Amit Thaper