Android – Manage click and longclick in listview


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 ?




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

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

Answered By – keyser

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.