Coming from a Java background I am used to dealing with actions though I'm not really sure why the method requires a boolean is returned and don't fully understand the explanation given on the site: true if the callback consumed the long click, false otherwise.
As you may know, the View
hierarchy in Android is represented by a tree. When you return true
from the onItemLongClick()
- it means that the View
that currently received the event is the true event receiver and the event should not be propagated to the other Views
in the tree; when you return false
- you let the event be passed to the other Views
that may consume it. Hope this helps.
I will further clarify this for you, by way of an example.
@Override
public boolean onLongClick(View view) {
//Do all you stuff here
return true; // or you can return false;
}
So, after your onLongClick() has fired, if you don't want the regular onClick() to fire, then just return true from the onLongClick() event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With