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

          主站蜘蛛池模板: 临武县| 左贡县| 乌苏市| 宣城市| 伽师县| 依安县| 黄石市| 弥渡县| 兴义市| 桂东县| 三明市| 射阳县| 衡东县| 盘锦市| 平山县| 平塘县| 宁安市| 施甸县| 邵阳县| 乌苏市| 北流市| 闻喜县| 明水县| 潜江市| 武山县| 文成县| 阿图什市| 桦甸市| 丽水市| 山东省| 磐安县| 全南县| 桂阳县| 德庆县| 慈利县| 嵊州市| 乌兰浩特市| 奇台县| 桃江县| 元氏县| 尼玛县|