Other answers are incorrect, there is one big difference.
When you add a title to the ListView, the ListView wraps the adapter in the HeaderViewListAdapter. The HeaderViewListAdapter job translates position
to accept headers.
For example, if you added one header, position 1
corresponds to the base adapter position 0
. If you tried to use adapter.getItem (position), it will actually return you the second element in the adapter.
If you added a title, you should use listView.getItemAtPosition (position).
source share