mytechead

Android & Wordpress Help center

set Text color programmatically

Well, although it was never thought by me that to I will be writing a blog page for telling users how to set color of a TextView programmatically- but setting android’s TextView programmatically requires few more efforts than one can possibly think of, which is why I decided to create this post –

In order to set color of a TextView, TextView.setTextColor(R.color.YOURCOLOR) is not enough!

It has to be used like this –

TextView myText = (TextView) findViewById(R.id.mytext);

myText.setTextColor(getResources().getColor(R.color.YOURCOLOR);

Advertisements

Single Post Navigation

One thought on “set Text color programmatically

  1. its working perfectly.. thanks for post…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: