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日发表在AndroidJAVA分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。 
转载请注明: Android Service中显示Toast的方法
标签: java小技巧

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()