Question

I have read some code that people use something like this

view.setOnLongClickListener(null);

What does it means and for what can be useful ? why someone uses this ?

is that the same as this

view.setOnLongClickListener(new OnLongClickListener() {

    public boolean onLongClick(View v) {
        return true;
    }
});
Was it helpful?

Solution

Null would remove any callbacks that are currently set as the views listener.

It definitely isn't the same as the second one, which assigns a listener to the view to control what will happen when you perform a long click on your view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top