Differnce between click event in ListView Android

103 views Asked by At

I am doing a listView on android to display the list of all collection points, each with area and address, then user can click to each item and delete/edit it. ListView is populated by an array adapter with class Collection point.

When I try to set the action for user to click on a specific item on listview, I found there are some options: setOnItemSelectedListener vs setOnItemClickListener and setOnClickListener what is the differences between those, and which situation we should use each ? P/s: can you also explain the difference between onClick and onLongClick Thank you !

2

There are 2 answers

0
Krishna On BEST ANSWER

onClick is used to invoke a specific operation when we simply click on the listview item where as onLongClick is used when we click on the list item for long time(hold the item more than 1 sec and release.

setOnItemClickListener is used when the item is clicked (single selection) vs setOnItemSelectedListener for the item is selected (used in multiple selection)

setOnClickListener is used to clicking event for button, txtview, imgview..

0
Myat Min Soe On

setOnItemSelectedListener is triggered when you touch down the screen. setOnItemClickListener is triggered when you touch down and up the screen. onClick is triggered when you touch down and up the screen. onLongClick is triggered when you touch down and hold for a second.