方法一:
使用 Activity.this.runOnUIThread()
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);// 使当前UI 线程休眠2000毫秒
// 更新UI线程
WelcomeActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "text",
Toast.LENGTH_SHORT).show();
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();