How to change TextColor of TextView through Java Code?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to change TextColor of TextView through Java Code?

Postby prajkti.khadse » Wed Apr 01, 2009 2:03 pm

Hi all

i want to change the text color of text in TextView through Java file(not through xml)

i've tried setTextColor(int color) method of TextView class.

but not getting what to provide as the parameter color. :oops:

please help....
prajkti.khadse
Developer
Developer
 
Posts: 32
Joined: Thu Mar 19, 2009 1:01 pm
Location: Bangalore

Top

Postby stifry » Wed Apr 01, 2009 5:37 pm

You have a couple options:

Set the text color using one of the default colors:

Code: Select all
countDownView.setTextColor(Color.GREEN);


or a custom color:

Code: Select all
colorRed = Color.argb(255, 248, 51, 6);

countDownView.setTextColor(colorRed);
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Postby prajkti.khadse » Thu Apr 02, 2009 4:30 am

hi stifry,

thanks a lot.... it worked.....
prajkti.khadse
Developer
Developer
 
Posts: 32
Joined: Thu Mar 19, 2009 1:01 pm
Location: Bangalore

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests