隨筆-348  評論-598  文章-0  trackbacks-0
          增加了按鈕之后,列表條目不能點擊的原因是:需要把Button的相關屬性設置成這樣
          android:focusable="false"
          不過在開發過程中,我有個動態獲取圖片并刷新列表的機制,發現每次調用完notifyDataSetChanged()方法之后Button都不能點擊了,后來發現如果有圖片動態加載那么每次都要重新inflate整個列表的條目,所以我干脆重載了notifyDataSetChanged()方法。
              /**
               * Recycle bitmap resources
               
          */
              
          public void recycleBitmapRes() {
                  
          if (mConvertViews != null && !mConvertViews.isEmpty()) {
                      Collection
          <View> views = mConvertViews.values();
                      mConvertViews.clear();
                      
          for (View view : views) {
                          ImageView icon 
          = (ImageView) view.findViewById(R.id.imgIcon);
                          
          if (icon != null) {
                              
          if (icon.getDrawable() != null && icon.getDrawable() instanceof BitmapDrawable) {
                                  Bitmap bitmap 
          = ((BitmapDrawable) icon.getDrawable()).getBitmap();
                                  
          if (bitmap != null && !bitmap.isRecycled()) {
                                      bitmap.recycle();
                                  }
                              }
                          }
                      }
                  }
              }
              @Override
              
          public void notifyDataSetChanged(){
                  
          //Avoiding that buttons cannot be pressed
                  Utils.LogI("GameListAdapter""notifyDataSetChanged");
                  recycleBitmapRes();
                  
          super.notifyDataSetChanged();
              }


          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2011-03-19 17:03 TiGERTiAN 閱讀(10422) 評論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 宜宾县| 通化市| 肃南| 敦煌市| 巨野县| 石景山区| 清新县| 清河县| 隆化县| 泸定县| 阳春市| 长寿区| 兴国县| 寻甸| 五指山市| 洮南市| 康乐县| 双牌县| 安新县| 上栗县| 通渭县| 宽城| 方正县| 岫岩| 保亭| 鄂伦春自治旗| 宁化县| 东山县| 临武县| 聂荣县| 温泉县| 镇巴县| 彰化市| 察隅县| 手游| 万宁市| 肇庆市| 醴陵市| 蚌埠市| 微博| 长治市|