MBH
MBH

Reputation: 16609

how to stop handler posted on view - android

Simply i post a runnable with delay on views using this code:

view.postDelayed(new Runnable() {
                    public void run() {
                        // Do Something
                    };
                }, delay);

I need to stop and remove this runnable sometimes. The idea is that there is delay, sometimes i need to stop it and ignore the delay and everything.

so how to stop it !?

Upvotes: 2

Views: 534

Answers (1)

Blackbelt
Blackbelt

Reputation: 157437

calling view.removeCallbacks(null);. Passing null as parameter removes every Runnable associated with the handler.

Upvotes: 3

Related Questions