How to unsubscribe from onTouch() event

When application is started I run a custom pop-up till a user touches the screen. When screen is touched I catch it with event onTouch() and cancel the pop-up. From this point I don't need the event anymore. The problem is the event is alive and continues to jump up every time a user touches the screen. Is there any way to unsubscribe from this event? Something like in c# -= eventName. The code is below:

public boolean onTouch(View v, MotionEvent event) {
    if (!_stopToast)
    _stopToast = true;
    return false;


There's no such method (lets say removeTouchListener or similar) which will help you to remove an already defined touch listener from a view. Setting null to setOnTouchListener won't help too. What you can do is to create a new object reference of OnTouchListener class which does nothing and set it in setOnTouchListener. For example:

public final OnTouchListener dummyOnTouchListener = new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent rawEvent) {
        return false;

And simply use it as below:


Need Your Help

Can I use Ajax and ASP.NET Tracing on the same page? ajax tracing

I'm using an Ajax update panel and have recently added ASP.NET tracing code to aid in debugging. All of the sudden I started getting PageRequestManagerParseErrorExceptions when any Ajax code is exe...

How do I get vim's :sh command to source my bashrc?

unix vim shell

Whenever I start a shell in vim using :sh, it doesn't source my ~/.bashrc file. How can I get it to do this automatically?