// 新建一个toast对象 private Toast toast; public void toastShow(String arg) { if (toast == null ) { toast = Toast.makeText( this , arg, Toast.LENGTH_SHORT); } else { toast.cancel(); toast.setText(arg); } toast.show(); } |
使用的时候直接调用
toastShow("content");