0

I set up several ClickListener events (using the setOnClickListener function). Now I'd like to disable (or deactivate, remove, delete) some of them temporarily and I can't find a way to do so.

Thanks in advance.

4
  • BTW, I am using Android SDK 2.3
    – thomaus
    Commented Dec 16, 2010 at 11:15
  • What does it mean 'temporarily'? could you just comment them and uncomment when you need them againg? Commented Dec 16, 2010 at 11:26
  • can you get boolean flags? for the events on which you want to disable that click event? If answer is yes you can call something like this: public void setOnClickListener(....){ if(canProceed){ perform your procedure here}} you can make canProceed=false on the events you want to disable the listeners. and than on your convenience you can make it true.
    – Prasham
    Commented Dec 16, 2010 at 12:23
  • Of course, I could comment / uncomment the event using a flag, but in ActionScript you have the option to remove an event listener, which I think is very useful. I was wondering if such an option exists for the Android SDK.
    – thomaus
    Commented Dec 16, 2010 at 12:51

1 Answer 1

2

Call setOnClickListener(null).

2
  • This compiles, but doesn't change the click event behavior. :-(
    – thomaus
    Commented Dec 16, 2010 at 12:51
  • @user544659: It should. The source code shows that it nulls out the internal data member used for holding the listener. Commented Dec 16, 2010 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.