android change list item in listview with custom adapter

i would like to change the background color from my listview. the background from the number should change by the status

1 = red
2 = grey
3 = green
4 = yellow

thats the code from my custom adapter(don't work):

TextView number = (TextView) rowView.findViewById(;

case 1: number.setBackgroundColor(0xff0000);

case 2: number.setBackgroundColor(0xdfdfdf);

case 3: number.setBackgroundColor(0x00ff00);

case 4: number.setBackgroundColor(0xffff00);

default :

why it doesn't work?


When you're setting background for a widget, you'll also need to add the alpha channel to the colour you wished to use since Android requires the colour to be in the format #ARGB, for example #AARRGGBB, where A is the alpha channel, and RGB is Red Green Blue.

So, in your case, if you want transparent (00 prefix) alpha channel, then you need to do this for case 1:


Or, for opaque channel (ff prefix), do this:


Need Your Help

Do I have to open the cursor to be able to use %FOUND or %NOTFOUND cursor attributes for an implicit cursor?

sql oracle plsql oracle10g database-cursor

Is it possible to execute c_emp%notfound after the following FOR loop or do I have to open the cursor first?

Web-Service vs Client-Server Distributed Computing Technology

web-services client-server

Premising that I'm a newbie in Web Services technologies, and am just beginning to study them, I wasn't able to understand in a precise way why should I implement a Web Service rather than a standard

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.