隨筆-348  評論-598  文章-0  trackbacks-0
          增加了按鈕之后,列表?xiàng)l目不能點(diǎn)擊的原因是:需要把Button的相關(guān)屬性設(shè)置成這樣
          android:focusable="false"
          不過在開發(fā)過程中,我有個動態(tài)獲取圖片并刷新列表的機(jī)制,發(fā)現(xiàn)每次調(diào)用完notifyDataSetChanged()方法之后Button都不能點(diǎn)擊了,后來發(fā)現(xiàn)如果有圖片動態(tài)加載那么每次都要重新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();
              }


          ---------------------------------------------------------
          專注移動開發(fā)

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2011-03-19 17:03 TiGERTiAN 閱讀(10422) 評論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 黄梅县| 陵川县| 栖霞市| 西和县| 高雄市| 和静县| 石首市| 本溪| 富顺县| 营口市| 蒲城县| 湖口县| 饶平县| 纳雍县| 澜沧| 峨山| 库伦旗| 双辽市| 大丰市| 嫩江县| 永安市| 涟水县| 年辖:市辖区| 南投市| 塔城市| 都江堰市| 元朗区| 马龙县| 神农架林区| 海口市| 塔河县| 黔西| 禹州市| 乌审旗| 神农架林区| 获嘉县| 隆德县| 万载县| 增城市| 大港区| 南通市|