0
我从Web服务中检索图像和文本的列表。图像显示在列表视图中。但问题是,当我向下滚动列表时,整个图像再次被加载。当我滚动两次或三次有一个OutofMemory发生......任何人都可以告诉我如何缓存图像,也避免加载的图像,当我向下滚动已经加载。我曾试图增加inSampleSize但它没有工作......下面的代码....缓存检索的图像
public static Bitmap loadImageFromUrl(String url) {
InputStream inputStream;
Bitmap b;
try {
inputStream = (InputStream) new URL(url).getContent();
BitmapFactory.Options bpo= new BitmapFactory.Options();
b=BitmapFactory.decodeStream(inputStream, null, bpo);
b.recycle();
bpo.inSampleSize = 2;
return b;
} catch (IOException e) {
throw new RuntimeException(e);
}
// return null;
}