我用的是这个架包:universal-image-loader-1.8.4-with-sources(2).jar 倒入后添加一个java类:
public class GlobalApplication extends Application {
public static ImageLoader imageLoader = ImageLoader.getInstance();
public static DisplayImageOptions options;
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
initImageLoader(getApplicationContext());
}
public static void initImageLoader(Context context) {
// This configuration tuning is custom. You can tune every option, you
// may tune some of them,
// or you can create default configuration by
// ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context).threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging()
// Not
// necessary
// in
// common
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
// imageLoader.init(ImageLoaderConfiguration.createDefault(context));
}
public static DisplayImageOptions getOptions() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher)// 加载等待 时显示的图片
.showImageForEmptyUri(R.drawable.ic_launcher)// 加载数据为空时显示的图片
.showImageOnFail(R.drawable.ic_launcher)// 加载失败时显示的图片
.cacheInMemory().cacheOnDisc()
/**
* .displayer(new RoundedBitmapDisplayer(20))
**/
.build();
;
return options;
}
}