How to prevent Multiple Toast Overlaps

后端 未结 8 1078
难免孤独
难免孤独 2020-11-29 07:26

I\'ve been using a common \"myToast\" which I use \"myToast.cancel() prior to issuing a new toast. For Android v2.3 and older, this works great. When a new toas

8条回答
  •  既然无缘
    2020-11-29 07:49

    Instead of calling cancel(). Try resetting the text and call show(). This should cancel the last toast by itself

    myToast.setText("wrong key")
    myToast.show();
    

    If you keep using the same myToast instead of creating one every time I guess they won't stack up.

提交回复
热议问题