Wednesday, November 4, 2009

[android-developers] Re: Subclass of ArrayAdapter not working

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 <mmur...@commonsware.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate