Android Toast提示封装实例代码
程序员文章站
2023-11-24 21:53:10
android toast提示封装
android中经常用到toast提示,项目中很多toast提示,写很长的一行,简单的封装一下,将toast方法提出来,很方便使用:...
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.
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!