An adapter is a kind of connection between AdapterView (ListView, GridView, etc.) and data arrays. The adapter generates flags that will be displayed in the AdapterView. Therefore, when the ListView needs to display elements, it first calls the adapter's getCount () method, after some measurements, it calls several getView () calls to fill the visible part of the list with the elements. And then, while scrolling, the ListView will call getView () from the adapter for the following items. It is important not to make any assumptions about the order of the getView () calls - it is not necessary that listview calls getView () in the same order as your data. Therefore, you donβt need to worry about increasing the position index - this argument is used for a situation, for example, when you need to display two different backgrounds for even and odd lines - and you can use the position to decide which color you need to use. There is a good presentation on the anatomy of ListView
source share