Android Toast提示封装_Android, Python及开发编程讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Android, Python及开发编程讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2047 | 回复: 1   主题: Android Toast提示封装        下一篇 
white
注册用户
等级:少校
经验:1327
发帖:305
精华:0
注册:2011-7-21
状态:离线
发送短消息息给white 加好友    发送短消息息给white 发消息
发表于: IP:您无权察看 2015-12-21 15:20:23 | [全部帖] [楼主帖] 楼主

Android中经常用到Toast提示,项目中很多Toast提示,写很长的一行,简单的封装一下,将Toast方法提出来,很方便使用:


/** 
     * 提示字符串 
     * short Toast 
     * @param context 
     * @param text 
     * by Hankkin at:2015-10-07 21:14:43 
     */  
    public static void showToast(Context context, String text) {  
        Toast toast = Toast.makeText(context,text,Toast.LENGTH_SHORT);  
        toast.setGravity(Gravity.CENTER,0,0);  
        toast.show();  
    }  
    /** 
     * 提示字符串 
     * short Toast 
     * @param context 
     * @param text 
     * by Hankkin at:2015-10-07 21:14:43 
     */  
    public static void showLToast(Context context, String text) {  
        Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG);  
        toast.setGravity(Gravity.CENTER, 0, 0);  
        toast.show();  
    }  
    /** 
     * 提示根据ResId关联字符串 
     * short Toast 
     * @param context 
     * @param resId 
     * by Hankkin at:2015-10-07 21:14:43 
     */  
    public static void showToast(Context context, int resId) {  
        Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);  
        toast.setGravity(Gravity.CENTER, 0, 0);  
        toast.show();  
    }  
    /** 
     * 提示根据ResId关联字符串 
     * 时常long   Toast 
     * @param context 
     * @param resId 
     * by Hankkin at:2015-10-07 21:14:43 
     */  
    public static void showLToast(Context context, int resId) {  
        Toast toast = Toast.makeText(context, resId, Toast.LENGTH_LONG);;  
        toast.setGravity(Gravity.CENTER, 0, 0);  
        toast.












赞(0)    操作        顶端 
云浅月93
注册用户
等级:少尉
经验:328
发帖:0
精华:0
注册:2015-12-4
状态:离线
发送短消息息给云浅月93 加好友    发送短消息息给云浅月93 发消息
发表于: IP:您无权察看 2015-12-23 10:39:31 | [全部帖] [楼主帖] 2  楼



赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论