//适配器中的代码
//配置色彩模式为RGB_4444
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.bitmapConfig(Bitmap.Config.ARGB_4444)
.build();
ImageLoader.getInstance().displayImage(list.get(i).getImageUrl(),hodler.imageView,displayImageOptions);
//MyApp中的代码 ( 注意继承的是Application )
public class MyApp extends Application{
//ImageLoader来加载图片,并全局配置,配置本地缓存路径在SDCard下imagefile目录
@Override
public void onCreate() {
super.onCreate();
File file = new File(Environment.getExternalStorageDirectory(),"imagefile");
ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(this)
.diskCache(new UnlimitedDiskCache(file))
.build();
ImageLoader.getInstance().init(imageLoaderConfiguration);
}
}
最后不要忘记在清单文件中添加name 还有网络请求权限哦!