Saturday, May 31, 2014

Android ArrayAdapter getView's "convertView" Parameter

The ListView and ArrayAdapter doesn't create a new View for every item in the list. Instead, view items are pooled and recycled as the user scrolls through the list. So what "getView" does is that sometimes it requires you to create a new View (when "convertView" is null) or to re-use an existing view (when "convertView" is not null).

Therefore, in getView, you should do a null check for convertView. If it is null, create a new View, otherwise, just reuse it.

No comments:

Post a Comment