I\'m working on ListView
. I want to know when exactly getView()
is called. Is it called once the adapter is set? And does the line next to \"settin
getView()
is called for each item in the list you pass to your adapter.
It is called when you set adapter. When getView()
is finished the next line after setAdapter(myAdapter)
is called.
In order to debug getView()
you must toggle a breakpoint on it because you can't step into getView()
from setAdapter(myAdapter)
.
getView()
is also called after notifyDataSetChanged()
and on scrolling.
To be more clear, getView() is called whenever a new item is displayed on screen, at the count of displayed items. Which means, if you have 1 million items but 15 of them fits on screen, getView is called 15 times. Whenever you scroll up/down and new items appear, getView() is called for new ones. And you should be aware of recycler mechanism, too. Which holds a template item layout for each item type, and sends in this view to getView() method as convertView parameter, so you could use it in order to prevent layout inflation.