OnClickListener triggers after onLongClickListener

I have one View for which both onClickListener and onLongClickListener . When I long onClickListener View onClickListener triggers, I don’t need it to execute when I make a long click. Any ways to prevent it from executing during a long click?

+6
source share
2 answers

return true; from a long click callback to a signal that you have processed an event

+21
source

Returns true instead of false from onItemLongClick .

Reason: returns true if the callback consumes a long click, false otherwise.

Example:

 listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { // TODO Auto-generated method stub /****** Change Here true instead of false. *******/ return true; } }); 
+1
source

Source: https://habr.com/ru/post/897347/


All Articles