码迷,mamicode.com
首页 > 移动开发 > 详细

Android Toast(吐司) 简单封装

时间:2015-07-21 14:47:31      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:android   toast   吐司   时间叠加   

Android Toast(吐司)简单封装,且解决了Toast显示时间叠加问题。

public class ToastUtil {
    private static Toast toast=null;
    public static void showToast(Context context,String content){
        if(toast!=null) {
            toast.cancel();
        }
        toast=Toast.makeText(context,content,Toast.LENGTH_LONG);
        toast.show();
    }
}

使用

ToastUtil.showToast(MainActivity.this,getString(R.string.exit_app));




版权声明:本文为博主原创文章,未经博主允许不得转载。

Android Toast(吐司) 简单封装

标签:android   toast   吐司   时间叠加   

原文地址:http://blog.csdn.net/shenyuanqing/article/details/46985091

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!