public void SentToast(final String content, int type) { handler = new Handler(Looper.getMainLooper()); switch (type) { case 1: handler.post(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), content, Toast.LENGTH_LONG).show(); } }); break; case 2: handler.post(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), content, Toast.LENGTH_SHORT).show(); } }); break; default: handler.post(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), content, Toast.LENGTH_LONG).show(); } }); break; } }
该日志由 huanying 于2015年02月04日发表在Android, JAVA分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
转载请注明: Android Service中显示Toast的方法
标签: java, 小技巧
全站熱搜
留言列表