Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable()
{
public void run()
{
Toast toast = Toast.makeText(getApplicationContext(),"另一个线程中显示...",Toast.LENGTH_SHORT);
//toast.setGravity(Gravity.TOP,0, 220); //设置toast的位置
toast.show();
}
});
转自:http://blog.youkuaiyun.com/zfzf294990051/article/details/7440701
本文介绍如何在Android应用的主线程中利用Handler和Toast组件在另一个线程中显示消息。通过实例演示了如何创建Handler对象,并在后台线程中执行Runnable任务来触发Toast的显示。
1939

被折叠的 条评论
为什么被折叠?



