Detailed explanation and example code of Android listview position

When we use listview, we usually add a response event Android widget. AdapterView. OnItemClickListener。 For the position and ID parameters of onitemclicklistener, I believe some people have made some detours.

When using listview, we often see the position variable in the listening events of listview, such as onitemclicklistener (onItemClick), or in the adapter of listview (getview, getitem, getitemid, etc.). When we do not add a headerview to the listview, the position is consistent with the index of the data source collection. After adding a headerview, the position value in some places will change. If we do not understand it clearly, we often make some confusion.

After adding headerview to listview, all views will be handed over to headerviewlistadapter for processing, so we need to add headerview or footerview before setadapter, otherwise it will not be displayed.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>