控制活动Toast刷新
适用于 每次需要弹出吐司是 将原有吐司清楚,替换为新的吐司
public void showToast(String toastString) {
// 如果当前页没有吐司
if (toast == null) {
toast = Toast.makeText(getApplicationContext(), toastString, Toast.LENGTH_SHORT);
} else {
//关闭吐司显示
toast.cancel();
toast = Toast.makeText(getApplicationContext(), toastString, Toast.LENGTH_SHORT);
}
//显示吐司
toast.show();
}
本文介绍了一种在Android应用中控制Toast刷新的方法,该方法确保每次显示Toast时都会清除旧的Toast并显示新的内容,适用于需要频繁更新Toast信息的场景。
1627

被折叠的 条评论
为什么被折叠?



