隨筆-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 閱讀(10410) 評論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 林西县| 长寿区| 友谊县| 资中县| 宿州市| 靖远县| 明溪县| 清原| 鄂托克前旗| 新和县| 阳城县| 鄂托克旗| 济阳县| 乐业县| 綦江县| 仪陇县| 祁阳县| 永城市| 南安市| 鹰潭市| 宁晋县| 巴南区| 七台河市| 中阳县| 富平县| 梁山县| 营口市| 梅州市| 迁西县| 喜德县| 宣城市| 工布江达县| 南靖县| 边坝县| 澳门| 商都县| 库尔勒市| 武城县| 姚安县| 台南市| 务川|