增加了按鈕之后,列表?xiàng)l目不能點(diǎn)擊的原因是:需要把Button的相關(guān)屬性設(shè)置成這樣
android:focusable="false"
不過(guò)在開(kāi)發(fā)過(guò)程中,我有個(gè)動(dòng)態(tài)獲取圖片并刷新列表的機(jī)制,發(fā)現(xiàn)每次調(diào)用完notifyDataSetChanged()方法之后Button都不能點(diǎn)擊了,后來(lái)發(fā)現(xiàn)如果有圖片動(dòng)態(tài)加載那么每次都要重新inflate整個(gè)列表的條目,所以我干脆重載了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();
}
---------------------------------------------------------
專(zhuān)注移動(dòng)開(kāi)發(fā)
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2011-03-19 17:03
TiGERTiAN 閱讀(10397)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
Android