從Runnable派生你的子類,重載run()方法。
然後調用View.post(myRunnableObj)即可把你的Runnable對象增加到UI線程中運行。
boolean android.view.View .post(Runnable action)
Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread.
Parameters:
action The Runnable that will be executed.
Returns:
Returns true if the Runnable was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting.