11

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

shift66
  • 11,760
  • 13
  • 50
  • 83
pengwang
  • 19,536
  • 34
  • 119
  • 168

3 Answers3

17
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.

Ginsan
  • 344
  • 2
  • 8
8
Toast toast = yourToastCreationCode();

if (null == toast.getView().getWindowToken())
{
    yeahToastIsInvisible();
}
Denis Gladkiy
  • 2,084
  • 1
  • 26
  • 40
5

Based on Denis answer, but worked better for me.

Toast t;
t=Toast.makeText(getActivity(), "test", Toast.LENGTH_LONG);
t.show;

if (t.getView().isShown())
{
   //visible
}
stalker
  • 55
  • 1
  • 2