[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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Subclass of ArrayAdapter not working
jax wrote: 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? http://commonsware.com/Android/excerpt.pdf That is an excerpt from one of my books that talks about the process. Remember that the view you are recycling once held a row. Android does not somehow magically reset those rows to their original look. Hence, if you changed the color before, you may have to change it back. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Consulting/App Development: http://commonsware.com/consulting -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Subclass of ArrayAdapter not working
Thanks, I will check it out On Nov 4, 9:19 pm, Mark Murphy mmur...@commonsware.com wrote: jax wrote: 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? http://commonsware.com/Android/excerpt.pdf That is an excerpt from one of my books that talks about the process. Remember that the view you are recycling once held a row. Android does not somehow magically reset those rows to their original look. Hence, if you changed the color before, you may have to change it back. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Consulting/App Development:http://commonsware.com/consulting -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Subclass of ArrayAdapter not working
Actually Mark I went to buy your book on Amazon the other day and it is $417.24 ...??? The Busy Coder's Guide to Android Development by Mark L. Murphy (Paperback - Feb 6, 2009) 1 new from $417.24. What is with that? Is there another way to buy it? I am not in the US. On Nov 4, 10:53 pm, jax jackma...@gmail.com wrote: Thanks, I will check it out On Nov 4, 9:19 pm, Mark Murphy mmur...@commonsware.com wrote: jax wrote: 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? http://commonsware.com/Android/excerpt.pdf That is an excerpt from one of my books that talks about the process. Remember that the view you are recycling once held a row. Android does not somehow magically reset those rows to their original look. Hence, if you changed the color before, you may have to change it back. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Consulting/App Development:http://commonsware.com/consulting -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Subclass of ArrayAdapter not working
jax wrote: Actually Mark I went to buy your book on Amazon the other day and it is $417.24 ...??? The Busy Coder's Guide to Android Development by Mark L. Murphy (Paperback - Feb 6, 2009) 1 new from $417.24. What is with that? Is there another way to buy it? I am not in the US. _The Busy Coder's Guide to Android Development_ is not in print -- I licensed print rights to Apress, which publishes it as _Beginning Android_. The excerpt is from Version 2.1 of the *digital* edition of _The Busy Coder's Guide to Android Development_, available via the Warescription program for 35 USD: http://commonsware.com/warescription If you have additional questions about the books and such, post them on the [cw-android] Google Group, so we keep [android-developers] clear for Android QA: http://groups.google.com/group/cw-android Thanks for your interest! -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en