在Android开发过程中,我们常常遇到子线程更新UI的需求,例如在子线程进行耗时较长的下载,等下载完成之后,再去更新UI,提示用户下载完成,直接在子线程里更新UI,会得到报错提示:Only the original thread that created a view hierarchy can touch its views。
Android老手知道这是怎么回事,并且知道解决方案,新手只能去网上找答案,网上的答案告诉我们报错是因为子线程不能直接更新UI线程,也就是主线程的控件,必须通过And
touch事件最开始从Activity 的 dispatchTouchEvent() 方法开始的
/frameworks/base/core/java/android/app/Activity.java
/**
* Called to process touch screen events. You can override this to
* intercept all touch screen events before they are dispatched to the
* w