首先想一想你所用到过的下载并缓冲图片的工具:
1、SmartImageView
2、ImageLoader
一、SmartImageView
(1、使用)
1、SmartImageView的使用;
首先把SmartImageView的源文件导入工程里
2、在你想要下载图片的位置加入SmartImageView的视图,切记要写全View的地址;
3、在Activity中渲染SmartImageView,findViewById找到View后,可以直接调用smartImageView的setImageUrl方法。
4、方法传递三个参数:第一个参数是图片的路径,第二个参数为下载中失败的图片,第三个参数是下载中的图片
imageView.setImageUrl(imagePath, R.drawable.ic_launcher, R.drawable.ic_launcher);
(2、优势与弊端)
优势:
1、SmartImageView可以获取系统联系人的头像
2、可以方便的异步加载图片
3、支持图片的缓存
弊端:当系统没有可用内存的时候,smartImageView才会清理缓存,这是SmartImageView的弊端
/*:在使用SmartImageView需要注意的技术:不能直接使用Bitmap,应该将其放入SoftReference中,目的是为了避免因图片太大,消耗太多的系统内存
memoryCache = new ConcurrentHashMap<String, SoftReference<Bitmap>>();
/*:在获取联系人头像的过程中,需要调用两个类:ContentProvider ContentResovler