首页 > 移动平台 > 详细

Android--Toast时间

时间:2016-05-26 06:15:42      阅读:422      评论:0      收藏:0      [点我收藏+]
/**
	 * 
	 * 显示toast,自己定义显示长短。
	 * param1:activity  传入context
	 * param2:word   我们需要显示的toast的内容
	 * param3:time length  long类型,我们传入的时间长度(如500)
	 */
	public static void showToast(final Activity activity, final String word, final long time){
		activity.runOnUiThread(new Runnable() {	
			public void run() {
				final Toast toast = Toast.makeText(activity, word, Toast.LENGTH_LONG);
				toast.show();
				Handler handler = new Handler();
			        handler.postDelayed(new Runnable() {
			           public void run() {
			               toast.cancel(); 
			           }
			    }, time);
			}
		});
	}

Android--Toast时间

原文:http://www.cnblogs.com/wuyong0818/p/5529478.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!