Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Text Color for textView Android

In the string.xml file i use the following tag

 <string name="CodeColor" >"#0000ff"</string>

If I use

 textview1.setTextColor(Color.RED);

it works, but when I use

  textview1.setTextColor(TextViewStyles.this.getResources().getColor(R.string.CodeColor)); 

 or
 textview1.setTextColor(R.string.CodeColor);

it doen't work. Any suggestions...

Thanks in Advance

like image 225
kavya Avatar asked Sep 21 '12 05:09

kavya


1 Answers

You can use

  textView1.setTextColor(getResources().getColor(R.color.mycolor))

or

  textview1.setBackgroundColor(Color.parseColor("#ffffff"));

or

    textview1.setBackgroundColor(Color.RED);

or

    textView1.setBackgroundColor(R.color.black);
like image 94
Randroid Avatar answered Oct 28 '22 18:10

Randroid