Difference between onItemClickListener and OnItemSelectedListener of AdapterView

有些话、适合烂在心里 提交于 2019-12-03 04:06:42

问题


What is the difference between these two listeners,documentation says :

OnItemSelectedListener - Interface definition for a callback to be invoked when an item in this view has been selected.

OnItemClickListener - Interface definition for a callback to be invoked when an item in this AdapterView has been clicked.

Selection,Click aren't these equal on touch screen?


回答1:


OnItemSelectedListener is used for Spinners, and OnItemClickListener is used for ListViews.




回答2:


AdapterView.OnItemSelectedListener is invoked only when the newly selected position is different from the previously selected position or if there was no selected item.

However AdapterView.OnClickListener is invoked even you click the same item everytime.

http://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html



来源:https://stackoverflow.com/questions/4177507/difference-between-onitemclicklistener-and-onitemselectedlistener-of-adapterview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!