解决Toast重复弹出,Toast单例模式
来源:互联网 发布:php 明天时间戳 编辑:程序博客网 时间:2024/06/05 08:17
防止Toast多次弹出,网上看到的不错
import android.content.Context;
import android.widget.Toast;
/**
* @create date:2013-7-16
* @class describe:解决Toast重复弹出
*/
public class ToastUtil3 {
private static String oldMsg;
protected static Toast toast = null;
private static long oneTime=0;
private static long twoTime=0;
public static void showToast(Context context, String s){
if(toast==null){
toast =Toast.makeText(context, s, Toast.LENGTH_SHORT);
toast.show();
oneTime=System.currentTimeMillis();
}else{
twoTime=System.currentTimeMillis();
if(s.equals(oldMsg)){
if(twoTime-oneTime>Toast.LENGTH_SHORT){
toast.show();
}
}else{
oldMsg = s;
toast.setText(s);
toast.show();
}
}
oneTime=twoTime;
}
public static void showToast(Context context, int resId){
showToast(context, context.getString(resId));
}
}
- 解决Toast重复弹出,Toast单例模式
- 解决Toast重复弹出,Toast单例模式
- 利用单例模式,解决toast重复弹出的问题
- Android-外功篇-单例Toast,解决重复弹出
- 解决Android中Toast重复弹出问题
- Toast单例模式的实现,解决多个toast等待时间久的问题
- android实用小工具:只弹一次的toast,解决toast重复弹出的问题。
- Android 解决toast重复提示
- 实时更新toast文本值不重复弹出toast demo
- 显示全局的Toast 防止toast重复弹出
- 单例Toast
- 单例Toast
- Toast的单例
- 单例Toast
- Android-单例Toast
- 单例Toast?
- 单例Toast
- Toast单例
- LCD驱动调试常见问题总结
- Python学习笔记(二):循环
- The resource is not on the build path of a java project
- HTML中的表单
- Kolya and Tandem Repeat - CF#253 (Div. 2)B (443B) 哈希或水题
- 解决Toast重复弹出,Toast单例模式
- poj 1198 二维树状数组
- 虚拟化KVM的使用 - mouse without borders
- c编译错误--error:stray \357 in program及其引发的字符编码概述
- Borya and Hanabi - CF#253 (Div. 2)C (442A) 状压暴力枚举
- css span提示框 练习(不能用div)
- 电子商务网站测试经验总结
- python url请求 乱码 urllib.quote 中文
- UVA 10196 Morning Walk(欧拉回路)