图片下载和缓存功能源码
实现图片下载和缓存功能,可以将图片下载之后缓存到内存或者SD卡中。图片第一次从互联网下载之后,就会缓存到内存或者SD卡中。第二次再打开浏览时,就无需再从互联网下载,而是直接从内存或者SD卡中读取。 效果图说:第一幅图是第一次打开应用,所有图片都来自互联网,第二幅图是第二次打开应用,可以看到部分图片来自缓存,部分图片来自互联网。 This project came about as part of my blog post: http://www.senab.co.uk/2012/07/01/android-bitmap-caching-revisited/ Android-BitmapCache is a specialised cache, for use with Android Bitmap objects. I have added a sample app to the source since, which can also be downloaded from the Downloads tab above. The sample app shows you how to use the library by creating a ViewPager of images downloaded from the web. These are cached in the LruCache and/or Disk Cache.
用户评论