-
學習了查看全部
-
handler更新UI的四種方法查看全部
-
Handler分發消息的一些方法查看全部
-
四種更新ui的方法查看全部
-
handler 與 looper 與 messageQueue的關系查看全部
-
handle負責發送和處理消息,looper負責接受消息,并把消息隊列中的消息發給對應的handle MessageQueue就是一個存儲消息的容器查看全部
-
ViewRootImp是在onResume方法中初始化的,在onCreate方法中創建線程并執行,此時還沒有初始化ViewRootImp,所以沒法判斷更新UI的線程是不是主線程;ViewRootImp中包含線程的判斷查看全部
-
這一節主要要講的是什么東西,就是為了說明handlemessage 主要是在主線程中執行嗎查看全部
-
Handler--->MessageQueue---->Looper查看全部
-
class MyThread extends Thread{ public Handler handler; @Override public void run() { // Looper.prepare(); handler = new Handler(){ @Override public void handleMessage(Message msg) { System.out.println("UI----->"+Thread.currentThread()); } }; // Looper.loop(); } PS:也就是說當開啟一個線程的時候在里面使用handler機制傳遞信息更新UI的時候必須創建looper對象即:Looper.prepare(),然后調用Looper.loop()使其循環處理消息。這樣才不會報:can not create handler inside thread that has not called looper.prepare(),這樣的錯誤。查看全部
-
第四種更新UI的方式:查看全部
-
在updateUI方法中使用runOnUIThread方法更新UI的方式:查看全部
-
復用系統的message查看全部
-
message.obj = person查看全部
-
第一種更新UI的方式:先起一個線程實現run方法然后在run方法中使用handler的post方法在post方法中new一個runnable在runnable中重寫run方法,在run方法中更新UI、查看全部
舉報
0/150
提交
取消