Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between onItemClickListener and OnItemSelectedListener of AdapterView

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?

like image 301
Suresh Avatar asked Nov 14 '10 12:11

Suresh


People also ask

What is AdapterView OnItemSelectedListener?

public abstract void onItemSelected (AdapterView<?> parent, View view, int position, long id) Callback method to be invoked when an item in this view has been selected. This callback is invoked only when the newly selected position is different from the previously selected position or if there was no selected item.


2 Answers

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

like image 68
Bryan Denny Avatar answered Sep 19 '22 02:09

Bryan Denny


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

like image 30
user1611552 Avatar answered Sep 21 '22 02:09

user1611552