Appearance
原理
ImageLoader.getInstance().displayImage(String url,ImageView img,options);
options 可选填或不填
相关工具类
/**
* 异步加载本地图片工具类
*
* @author tan
*
*/
public class LoadLocalImageUtil {
private LoadLocalImageUtil() {
}
private static LoadLocalImageUtil instance = null;
public static synchronized LoadLocalImageUtil getInstance() {
if (instance == null) {
instance = new LoadLocalImageUtil();
}
return instance;
}
/**
* 从内存卡中异步加载本地图片
*
* @param uri
* @param imageView
*/
public void displayFromSDCard(String uri, ImageView imageView) {
// String imageUri = "file:///mnt/sdcard/image.png"; // from SD card
ImageLoader.getInstance().displayImage("file://" + uri, imageView);
}
/**
* 从assets文件夹中异步加载图片
*
* @param imageName
* 图片名称,带后缀的,例如:1.png
* @param imageView
*/
public void dispalyFromAssets(String imageName, ImageView imageView) {
// String imageUri = "assets://image.png"; // from assets
ImageLoader.getInstance().displayImage("assets://" + imageName,
imageView);
}
/**
* 从drawable中异步加载本地图片
*
* @param imageId
* @param imageView
*/
public void displayFromDrawable(int imageId, ImageView imageView) {
// String imageUri = "drawable://" + R.drawable.image; // from drawables
// (only images, non-9patch)
ImageLoader.getInstance().displayImage("drawable://" + imageId,
imageView);
}
/**
* 从内容提提供者中抓取图片
*/
public void displayFromContent(String uri, ImageView imageView) {
// String imageUri = "content://media/external/audio/albumart/13"; //
// from content provider
ImageLoader.getInstance().displayImage("content://" + uri, imageView);
}
}