Demonstrates how to write an efficient list adapter. The adapter used in this example binds
to an ImageView and to a TextView for each row in the list.
To work efficiently the adapter implemented here uses two techniques:
- It reuses the convertView passed to getView() to avoid inflating View when it is not necessary
- It uses the ViewHolder pattern to avoid calling findViewById() when it is not necessary
The ViewHolder pattern consists in storing a data structure in the tag of the view returned by
getView(). This data structures contains references to the views we want to bind data to, thus
avoiding calls to findViewById() every time getView() is invoked. |