I have seen a number of questions on cancelling toast. None of them is working.
I have a custom Toast. The code for that is all but one line same as http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView
The difference is as follows.
- The toast variable is defined as a class variable
- The entire java code is written in a method.
In the start of this method, I have added the following line to cancel the toast.
if (toast!=null){ toast.cancel(); }
The method is called when user selects (onClick) the view/layout. The issue is when the user selects few times, the toast will get queued up (the toast.cancel is not working).
Any solutions?
[update] I tried making toast object a static variable. Still dont work.