1、handler.post(new Runnable{ runj(); });
new Thread(){
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
textView.setText("update thread");
}
});
}
}.start();
2、handler.postDelayed(myRunnable, 1000);
new Thread(){
@Override
public void run() {
//在myRunnable更新UI
handler.postDelayed(myRunnable, 1000);
}
}.start();
3.handler.sendMessage(message);
//新建一个message或者使用handler.obtainMessage();从当前缓存池中得到一个message。
// Message message = new Message();
Message message = handler.obtainMessage();
Person person = new Person(23,"lhd");
message.obj = person;
message.sendToTarget();//使用message自身的方法发送
// handler.sendMessage(message);//使用handler的sendMessage方法发送消息
//在handler的handleMessage方法里更新UI
4.runOnUiThread(myRunnable);
new Thread() {
public void run() {
//在myRunnable更新UI
runOnUiThread(myRunnable);
};
}.start();