Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setOnItemClickListener VS setOnItemSelectedListener in ListView.

I wish to set an onClickListener on items of a ListView but I see two methods setOnItemClickListener and setOnItemSelectedListener . I didint find any justified explanation for these two in official docs. Which one to use for what purpose?

To select an item, the user will have to click the item then what is the use of different methods?

like image 692
Ayush Goyal Avatar asked Sep 06 '12 05:09

Ayush Goyal


2 Answers

It is like

the item is clicked (single selection) vs the item is selected (used in multiple selection)

like image 104
Aditya Nikhade Avatar answered Oct 26 '22 23:10

Aditya Nikhade


Difference between these to methods is presented in their description:

has been selected vs has been clicked

Actually, the difference is just the same as one between selected and clicked in Android terms. Select it's more like highlight, please refer to more detailed explanation about selected state here (under android:state_selected). Click is the same as pressed in android terms and described under the same link but under android:state_pressed.

like image 21
sandrstar Avatar answered Oct 26 '22 23:10

sandrstar