android 4.4.2 onListItemClick() and onItemLongClick() fired on long click

259 views Asked by At

Situation: I have a list activity, in which I have implemented the onListItemClicked() and the onItemLongClick() method. Using a Smart phone with android 4.4.2, both events are fired, when I actually only expect the longClick to be fired.

What might be the reason for this and is there any way to avoid it?

Thank you in advance for any ideas, suggestions and answers!

1

There are 1 answers

0
Robbe On BEST ANSWER

In the onLongClick method of your onLongClickListener, return true to indicate that you have consumed the click event.

public boolean onLongClick(View v) {
        // DO STUFF                 
        return true;
}

If you return false, you indicate that you haven't handled the event and/or want it to trigger any other on-click listeners.