避免Toast重复弹出

2023-09-11,

Toast.matkText才会创建一个新的实例

private Toast toast = null;

private void checkToastResult() {
if (toast != null) {
toast.setText("没有搜索结果");
toast.setDuration(Toast.LENGTH_SHORT);
} else {
toast = Toast.makeText(context, "没有搜索结果", Toast.LENGTH_SHORT);
}
toast.show();
}

避免Toast重复弹出的相关教程结束。

《避免Toast重复弹出.doc》

下载本文的Word格式文档,以方便收藏与打印。