Reputation: 3031
I am writing a code, where I will use more onClickListener for one View but I want it to have only one onClickListener
at time.
So my question is: Is it enough if I always call myView.setOnClickListener(MyListener)
or do I need to call myView.setOnClickListener(null)
always before I set a new listener to the view?
The documentation says only that it registers a callback, doesn't say anything about the previously registered callbacks.
Thank you for your answer!
Upvotes: 1
Views: 147
Reputation: 157467
So my question is: Is it enough if I always call myView.setOnClickListener(MyListener)?
yes it is enough. the setter, as the name says, sets
(assigns
) the reference you are providing as parameter, overriding any precedent assigned references.
The documentation says only that it registers a callback, doesn't say anything about the previously registered callbacks.
It doesn't because the name implies already it
Upvotes: 4