ToastUtil 多字符串toast 非主线程Toast
2016-08-16 00:00
405 查看
1.多字符串toast,一般用于开发时查知方法运行
2.非主线程中toast
2.非主线程中toast
import android.content.Context; import android.os.Handler; import android.widget.Toast; /** * Created by wangxingsheng on 16/8/10. */ public class ToastUtil { public static void talk(Context context, String... args){ StringBuilder sb = new StringBuilder(); String temp = ""; for (Object obj : args){ if(obj!=null){ temp = obj.toString(); }else{ temp = " *null* "; } sb.append(temp); } Toast.makeText(context,sb.toString(),Toast.LENGTH_SHORT).show(); } public static void talkInThread(final Context context, final String... args){ Handler handler = new Handler(context.getMainLooper()); handler.post(new Runnable() { @Override public void run() { talk(context,args); } }); } }
相关文章推荐
- ToastUtil【简单的Toast封装类】【未自定义Toast的显示风格】
- ToastUtil,一个简单的Toast封装
- android反编译静态调试实战1(Toast显示加密密匙和md5拼接前字符串)
- toast 字符串
- 一个简单的Toast工具类---ToastUtil
- ToastUtil Toast工具类的快捷使用
- 自定义ToastUtil工具类,可解决快速显示Toast文本问题
- 自定义样式和时长的Toast(AndroidToastUtil)
- DataFormatString格式字符串
- java中判断字符串是否为数字的方法的几种方法
- C# 判断中文字符(字符串)
- Oracle存储过程总结(二、字符串处理相关函数)
- 鸡啄米:C++编程入门系列之三十三(数组、指针和字符串:用字符数组存放和处理字符串)
- oracle有对比字符串相似度的函数
- Struts2中的s:if判断字符串是否相等要注意单引号和双引号
- Visual Studio 2010——C#中的字符串
- 在非Activity类里面启动Intent、Toast等。
- 字符串过滤
- 程序员面试题精选100题(36)-在字符串中删除特定的字符[算法]
- 生成URL编码请求字符串和解析URL编码请求字符串