Android - Manage click and longclick in listview

422 Views Asked by At

I am currently coding a new android Application, and I need to use both OnItemClickListener and OnItemLongClickListener on a listview. Each listener launch a different actionmode on the actionbar. The problem is that the actionmode associated with the click event is the only that is launched even if I perform a longclick. After some research, I understand now why : a long click event also create click event, and I guess that this last event is always perform after the long click event, so that explain why I can't manage to display the other actionmode.

The question is : how can I block the click event when i do a longclick ? Or does it exist another mean to perform what I want to do ?

1

There are 1 best solutions below

1
On BEST ANSWER

onLongClick():

Returns

true if the callback consumed the long click, false otherwise.

So, if you return true the onclick won't be executed.