Android Toast Android Toast提示封装实例代码
人气:0想了解Android Toast提示封装实例代码的相关内容吗,在本文为您仔细讲解Android Toast的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,Toast提示封装,Android,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.
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
加载全部内容