Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Hide all shown Toast Messages

How do I remove all toast messages currently displayed?

In my App, there is a list, when a user clicks on an item, a toast message is displayed, 10 items - 10 toast messages.

So if the user clicks 10 times, then presses the menu button, they have to wait for some seconds until they're able to read the menu option text.

It shouldn't be like that :)

like image 696
crazyV Avatar asked May 02 '10 22:05

crazyV


1 Answers

My solution was to initialize a single Toast in the activity. Then changing its text on each click.

Toast mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT); if (a) {   mToast.setText("This is a");   mToast.show(); } else if (b) {   mToast.setText("This is b");   mToast.show(); } 
like image 175
Mudar Avatar answered Sep 23 '22 22:09

Mudar