Remove an onclick listener
Note that if a view is non-clickable (a TextView for example), setting setOnClickListener(null)
will mean the view is clickable. Use mMyView.setClickable(false)
if you don't want your view to be clickable. For example, if you use a xml drawable for the background, which shows different colours for different states, if your view is still clickable, users can click on it and the different background colour will show, which may look weird.
mTitleView.setOnClickListener(null)
should do the trick.
A better design might be to do a check of the status in the OnClickListener and then determine whether or not the click should do something vs adding and clearing click listeners.