SmartImageView
一:概述(Load Images from URLs or Android Contacts with Caching)
SmartImageView
is a drop-in replacement(替代实现) for Android’s standard ImageView
which additionally(另外) allows images to be loaded from URLs or the user’s contact address book. Images are cached to memory and to disk for super fast loading.
二:Features(特征)
- Drop-in replacement for
ImageView ImageView控件的替代实现
- Load images from a URL 支持通过URL来加载图片
- Load images from the phone’s contact address book 支持从电话簿中加载图片
- Asynchronous loading of images, loading happens outside the UI thread 异步加载图片
- Images are cached to memory and to disk for super fast loading
- 图片被缓存在内存,以便下次快速加载显示;
SmartImage
class is easily extendable to load from other sources- SmartImageView类可以被很容易扩展成对其它资源的调用;
三:Installation & Basic Usage(安装与入门)
Download the latest .jar file from github and place it in your Android app’s libs/
folder.
下载最新的.jar文件从github网站并且放置它到你的android app的libs文件夹中
Add a SmartImageView
to your activity’s xml layout: 添加一个SmartImageView到你activity的xml布局文件
<com.loopj.android.image.SmartImageView
android:id="@+id/my_image" />
Get a reference to the layout’s SmartImageView
:
SmartImageView myImage = (SmartImageView) this.findViewById(R.id.my_image);
Load an image into the view from a URL: 通过URL来加载图片
myImage.setImageUrl("http://www.awesomeimages.com/myawesomeimage.jpg");
Load an image into the view from the phone’s contact address book: 从电话簿中加载图片
myImage.setImageContact(contactAddressBookId);
四:实例
商城中展示的主题商品图片就是使用这个开源框架的。