private MyHandler mHandler = new MyHandler(); ...... mHandler.sendResult(MyHandler.UPDATE_VIEW, null); ...... private class MyHandler extends Handler{ private static final int UPDATE_VIEW = 0; @Override public void handleMessage(Message msg) { switch (msg.what) { case UPDATE_VIEW: updateView(); break; default: break; } } private void sendResult(int result, Object obj) { Message message = new Message(); message.what = result; message.obj = obj; sendMessage(message); //obtainMessage(result, obj).sendToTarget(); //效率更高 } }
mView.post(new Runnable() { @Override public void run() { updateView(); } });
Android在非UI线程中更新UI的方法,布布扣,bubuko.com
原文地址:http://blog.csdn.net/heqiangflytosky/article/details/30244439