Context
I want to have a list with 3 significantly different layouts for list items so I make my adapter that based on type of item to display creates appropriate view.
e.g. i want to list some images, texts and numbers, each with some title.
I know that in
public View getView(int position, View convertView, ViewGroup parent)
the convertView
stands for reusing no longer visible listItems views.
Question
How can I choose the convertView
or how can i control what i get in there?
The problem comes with different listItems views, assume I have my list starting with an image listItem, then comes a lot of text listItems and number listItems and 100 listItems later comes second image.
I assume that while scrolling down the list, (in getView(...)
calls) the first convertView
that is not null is the one with image, and since i need a view to display text listItem or number listItem I cannot use it. Then i guess that in every next getView(...)
call the convertView
is that same image listItem as in previous calls because i didn't use it before.
The unused text listItems and number listItems stuck up and when scrolling the list I need to keep creating new views, this is what i want to prevent.