我们可以直接使用View对象调用post(runnable),是因为View里面有主线程Handler对象?是每个View都有一个Handler还是公共的。当View没有AttachedToWindow的时候View.post是无效的。
所有的View的post方法都是直接继承于View类的post(Runnable action)方法:
public boolean post(Runnable action) {
final AttachInfo attachInfo = mAttachInfo;
if (attachInfo != null) {
// 1. AttachInfo.mHandler 这里是Handler
return attachInfo.mHandler.post(action);
}
// Assume that post will succeed later
// 2.ViewRootImpl.getRunQueue() 返回的RunQueue
ViewRootImpl.getRunQueue().post(action);
return true;
}
AttachInfo.mHandler
其中的AttachInfo的mHandler是从外部传进来的,
AttachInfo(IWindowSession session, IWindo