隨筆 - 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 小一敗涂地 閱讀(12068) 評論(0)  編輯  收藏 所屬分類: android+移動開發錯誤集

          主站蜘蛛池模板: 张北县| 大厂| 边坝县| 千阳县| 安吉县| 青岛市| 镇安县| 城市| 施甸县| 徐州市| 西乌| 凤山市| 余庆县| 大姚县| 莒南县| 天全县| 禹城市| 图木舒克市| 沧州市| 襄垣县| 泗洪县| 微博| 工布江达县| 宁德市| 竹北市| 道孚县| 惠东县| 东宁县| 昭通市| 瑞安市| 运城市| 梅州市| 常熟市| 独山县| 乌海市| 罗定市| 谷城县| 桐梓县| 安西县| 林甸县| 望奎县|