隨筆 - 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+移動開發 、錯誤集

          主站蜘蛛池模板: 平南县| 梅州市| 邮箱| 桂阳县| 金湖县| 聂荣县| 黄陵县| 万荣县| 寿阳县| 丹棱县| 丰顺县| 南城县| 昆山市| 屏东市| 宜良县| 通山县| 梁山县| 阳新县| 保德县| 襄樊市| 天全县| 庆安县| 大埔县| 永登县| 九台市| 绍兴市| 彭州市| 准格尔旗| 三穗县| 阿瓦提县| 花垣县| 兴仁县| 延安市| 山阳县| 乐都县| 麻栗坡县| 石泉县| 雅江县| 灵川县| 定陶县| 科技|