可以将图像保存在应用程序缓存中,并将这些相同的图像用于图库。这些图像必须从互联网上下载。能给我解释一下怎么做吗?
问问题
211 次
2 回答
0
Yes you can,,
Use NetworkImageService
which will fetch image remotly from server.
class NetworkImageService {
public Image getImage(name) { ... }
}
Just make another subclass.
class CachedNetworkImageService extends NetworkImageService {
Cache cache = new Cache();
public Image getImage(name) { ...
Image img = cache.get(name);
if( img == null ) {
img = super.getImage(name);
cache.put( name, img );
}
return img.
}
}
Read about Hashmap. It will work...
于 2012-11-03T04:48:01.030 回答
0
我会为此使用 LruCache。在这里阅读文档。
于 2012-11-03T04:50:24.313 回答