Thanks it worked, I changed it to

                if(!item.contains("100%")) {
                        tv.setTextColor(Color.RED);
                }
                else {
                        tv.setTextColor(Color.BLACK);
                }

but I still don't understand why...

Do you know any sites that explain about recycling views?




On Nov 4, 8:45 pm, Mark Murphy <[email protected]> wrote:
> jax wrote:
> > I have subclassed ArrayAdapter to set the color of text to RED if the
> > string does not contain 100%, this has been added to a ListView.  The
> > problem is that some of the rows show as red when they contain 100%.
> > Why would this happen?
>
> You are recycling rows but not resetting their color. Hence, over time,
> most if not all of your rows will be red.
>
> >                 if(!item.contains("100%")) {
> >                    tv.setTextColor(Color.RED);
> >                 }
>
> In the above code snippet, also handle the "else" branch and reset the
> color to its normal state.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android App Developer Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to