当前位置: 移动技术网 > IT编程>移动开发>Android > Android Toast提示封装实例代码

Android Toast提示封装实例代码

2019年07月24日  | 移动技术网IT编程  | 我要评论

随想日语晶典,玉蒲团之淫行天下,辽西人才在线

android toast提示封装

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. 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网