开发者

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

This question already has answers here: Stop all toast messages when going to another screen in Android (3 answers) Closed 8 years ago.

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜