android - Listview of sent and received sms color change on scroll -


hi developing android sms app want display sent , received sms in 2 different colors on listview. if sent sms, changing color in adapter. if lets there 10 items on listview, below code works fine.

    if(type.equalsignorecase("1"))     {     //received sms        }     else if(type.equalsignorecase("2"))     {        //sent sms         msg.setbackgroundcolor(color.parsecolor("#d5f7c3"));         msgdt.setbackgroundcolor(color.parsecolor("#bdf8c7"));      } 

but on scrolling it, 11th item still remains previous view color. colors in listview keeps changing scroll , forth. have added android:cachecolorhint="#000000" listview. not sure going wrong. how resolve this? please help.

thanks!

i think using custom layout view in list item.

so happens when using custom layout inflate layout , used again next items.

so check condition in custom adapter's getview() similar this..

if(type.equalsignorecase("1")) {     //received sms       msg.setbackgroundcolor(color.parsecolor("#d5f7c3"));     msgdt.setbackgroundcolor(color.parsecolor("#bdf8c7"));     //set colors recieved sms.   } else if(type.equalsignorecase("2")) {    //sent sms     msg.setbackgroundcolor(color.parsecolor("#d5f7c3"));     msgdt.setbackgroundcolor(color.parsecolor("#bdf8c7"));     //set colors sent sms  } 

it work you.

(its code logic representation check criteria needs set you.)

hope helps!!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -