I have ListView
in which onItemClickListener
and onLongItemClickListener
are used for different options. It works fine in jellybean
. But in Nexus5
when I long click on the ListView
, both onItemClickListener
and onLongItemClickListener
are called. Why is this happening? Does anyone know about it?
You should set the return value of the OnItemLongClickListener
to true
private AdapterView.OnItemLongClickListener itemLongClickListener = new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//... Do stuff
return true;
}
};
This is how the event tells its parent that the click event has been handled. If it is set to false the OnItemClickListener
will also be fired, invoking its listener method as well.