In getView method of gallery ,
i had download the bitmap and set to Imageview and return it back to framework.
When and where should i recycle the bitmap ?
I don’t want to wake up the system garbage collector to clean up the bitmaps.
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);
}
1 Answer