隨筆-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
          主站蜘蛛池模板: 巴南区| 盈江县| 东源县| 建德市| 广汉市| 乌拉特前旗| 霍林郭勒市| 九龙城区| 仲巴县| 台前县| 忻城县| 满洲里市| 宁陵县| 潮州市| 许昌市| 日照市| 肇庆市| 民县| 康平县| 宣化县| 新晃| 铜川市| 舞阳县| 南开区| 全南县| 邯郸市| 志丹县| 乾安县| 崇左市| 利辛县| 和田市| 衡阳市| 普兰店市| 淮滨县| 江安县| 西乌珠穆沁旗| 乌鲁木齐市| 崇仁县| 玉林市| 师宗县| 平安县|