Toast单例

来源:互联网 发布:pdf解密软件在线 编辑:程序博客网 时间:2024/06/05 09:30
Toast toast=Toast.makeText(cordova.getActivity(),"请在系统设置开启相机权限",Toast.LENGTH_LONG);
showtoast(toast,4000);
//设置吐司时长
public voidshowtoast(finalToast toast,finalint cnt){
final Timertimer=new Timer();
timer.schedule(newTimerTask() {
@Override
public voidrun() {
toast.show();
}
},0,cnt);
new Timer().schedule(newTimerTask() {
@Override
public voidrun() {
toast.cancel();
timer.cancel();
}
},cnt);
}

原创粉丝点击