This is functionality that you should write into your adapter class. Do not circumvent the adapter. The list view is relying on the adapter to serve up views, and the adapter is performing recycling so that new views don't have to be inflated every time the user scrolls up and down.
Adapters have a couple methods that are designed to let you serve up different views for different list view rows: getItemViewType(int position)
and getViewTypeCount()
. For every different type of row you want to inflate, have a different private method to do the inflation (or recycling, just like you normally would with the ViewHolder pattern). In your getView()
method, call the appropriate private helper to inflate the view, based on what type of list item it is -- your view can be just about anything.