Android's ListView Recycle Bin
This blog post is going to be a reminder for me and I hope would be good information for other people on how Android's ListView works. So everybody knows that Android doesn't create a new list item view (iOS people would call it UITableViewCell) for every items in a list view, but it recycles them when you scroll, so the list view doesn't create too many objects. However, there are times that you want to have a special list view item that will have a different type of view in the list view, and you only use that view one at a time. A stupid implementation of this would be creating a single instance of the view as an instance variable and return that in your list adapter. However, it DOES NOT work. It will look like it works fine, but the problem is your getView() will get called so many times in a second and it degrades your performance. I found that as a nasty bug in my program. So to fix it, what my colleague and I did was we actually just create a new view within the getView() method and let the Android's list view manage everything. I found that if you try to outsmart the system, things will not work as well as you think it might be. So, basically, this is a lesson for me that I should not try to "overly" optimize my program, and try to follow the framework as much as I can so I don't break anything serious. :)