public final boolean post (Runnable r) Since: API Level 1 Causes the Runnable r to be added to the message queue. The runnable will be run on the thread to which this handler is attached. 谢谢楼上的各位,post (Runnable r)中Runnable对象确实是在创建handler的线程中(本例是主线程)执行。
你还需要执行new Thread(myThread ).start();来启动新线程,Thread有个参数为runnable对象的构造函数。
我也是前几天才明白这个问题。
Since: API Level 1 Causes the Runnable r to be added to the message queue. The runnable will be run on the thread to which this handler is attached.
谢谢楼上的各位,post (Runnable r)中Runnable对象确实是在创建handler的线程中(本例是主线程)执行。