custom listview adapter getView method being called multiple times, and in no coherent order
This is not an issue, there is absolutely no guarantee on the order in which getView()
will be called nor how many times. In your particular case you are doing the worst thing possible with a ListView
by giving it a height=wrap_content
. This forces ListView
to measure a few children out of the adapter at layout time, to know how big it should be. This is what provides ListView
with the convertViews
you see passed to getView()
even before you scroll.
Try with match_parent
on the layout_height
property of the list view. It will prevent getView()
to be called so often.
I got rid of this issue when I changed both layout_width and layout_height to match_parent (changing only layout_height didn't help).
Helpful note watch out if you have nested items. You've got to change the "highest" one to match_parent. Hope it helps someone.