how to check if the toast have dismissed or not [duplicate]
i want to check if the toast have dismissed or not ,because user click the mouse the toast is show,but 开发者_Python百科may me the user continuous click,so i need to check,i cannot use the dialog
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.
Toast toast = yourToastCreationCode();
if (null == toast.getView().getWindowToken())
{
yeahToastIsInvisible();
}
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
}
精彩评论