Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check if the toast have dismissed or not [duplicate]

Tags:

android

i want to check if the toast have dismissed or not ,because user click the mouse the toast is show,but may me the user continuous click,so i need to check,i cannot use the dialog

like image 670
pengwang Avatar asked May 06 '11 06:05

pengwang


People also ask

How do you show errors in Toast?

So basically, Toast. makeText(getBaseContext(),"Your message", Toast. LENGTH_LONG). show(); will generate the toast message and if you want to it to be displayed for some particular case, then just put the condition inside the if statement.

What is the features that Toast can not be done?

Toast cannot :Be focused or clicked. This makes a huge inconvenience to visually impaired. Notify application about its current status, e.g. the callback of dismiss.

What are the three essential parameters for Toast makeText function?

Use the makeText() method, which takes the following parameters: The application Context . The text that should appear to the user. The duration that the toast should remain on the screen.

What method call is used to display a Toast notification?

Display the created Toast Message using the show() method of the Toast class. The code to show the Toast message: Toast. makeText(getApplicationContext(), "This a toast message", Toast.


2 Answers

Toast toast = null;
if (toast == null || toast.getView().getWindowVisibility() != View.VISIBLE) {
    toast = Toast.makeText(getApplicationContext(),
        "Text", Toast.LENGTH_SHORT);
    toast.show();
}

Check if the toast is visible before you show it again.

like image 57
Ginsan Avatar answered Oct 11 '22 09:10

Ginsan


Toast toast = yourToastCreationCode();

if (null == toast.getView().getWindowToken())
{
    yeahToastIsInvisible();
}
like image 34
Denis Gladkiy Avatar answered Oct 11 '22 10:10

Denis Gladkiy