在图库的getView方法中, 我下载了位图并设置为Imageview并将其返回到框架。 我何时何地回收位图? 我不想唤醒系统垃圾收集器来清理位图。
public View getView(int position, View view, ViewGroup parent) {
ImageView i = new ImageView(mContext);
downloadFromWeb("www.blahblah.com", i);
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setLayoutParams(new Gallery.LayoutParams(mDisplayWidth, (mDisplayHeight-100)));
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
public downloadFromWeb(URL url, ImageView i){
Bitmap bitmap = getBitmapFromWeb(url);
i.setImageBitmap(bitmap);
}
答案 0 :(得分:0)
You can call bitmap recycle method in onDestory method as shown below
Bitmap mybitmap= null;
@Override
protected void onDestroy() {
super.onDestroy();
if(bm!=null)
mybitmap.recycle();
}