隨筆 - 0, 文章 - 264, 評論 - 170, 引用 - 0
          數據加載中……

          Can't create handler inside thread that has not called Looper.prepare()

          在android開發中,遇到這個問題:
          Can't create handler inside thread that has not called Looper.prepare()

          問題原因:
          在android的多線程開發中,比如asyncTask,在其doInBackground()方法,調用了更新UI的方法。

          解決辦法:
          把更新UI的操作,放到消息處理器中處理;在doInBackground()方法中發送更新消息:
          Handler updateDate = new Handler(){
                   @Override
                   public void handleMessage(Message msg) {
                       switch(msg.what){
                           case LOADING_FINISHED:
                               listView.setAdapter(gameAdapter);
                               break;
                       }
                   }
               };

          posted on 2011-08-31 11:28 小一敗涂地 閱讀(12067) 評論(0)  編輯  收藏 所屬分類: android+移動開發錯誤集

          主站蜘蛛池模板: 吉安县| 蒙自县| 横峰县| 渑池县| 宜昌市| 军事| 冀州市| 德清县| 舟山市| 上犹县| 临湘市| 涡阳县| 清水河县| 张北县| 石林| 康定县| 遂平县| 伊春市| 赤城县| 天镇县| 洛南县| 于都县| 崇礼县| 年辖:市辖区| 黑龙江省| 敦煌市| 东兰县| 博野县| 马龙县| 绥棱县| 福贡县| 沁水县| 桐柏县| 华蓥市| 深泽县| 汶上县| 丰城市| 古蔺县| 荥经县| 增城市| 漳浦县|