注意： onDraw方法是运行于主UI线程中的，如果你在onDraw中执行invalidate()方法去更新屏幕，是可以的。但是你既要继承View而且要不希望堵塞主UI线程的话，可以另外新建线程，然后在线程中执行postInvalidate()方法去更新屏幕。也就是说invalidate()方法只能在主UI线程中被调用，postInvalidate()方法只能在非主UI线程中被调用。否则会出现如下error08-08 15:33:34.587: E/AndroidRuntime(4995): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.这两个方法只是再次调用onDraw方法而已。Invalidate the whole view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().