public class MyApp extends Application {
public void onCreate() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.ic_launcher).cacheInMemory(true)
.cacheOnDisk(true).displayer(new FadeInBitmapDisplayer(1500))
.build();
ImageLoaderConfiguration configs = new ImageLoaderConfiguration.Builder(
this).memoryCacheExtraOptions(480, 800)
.diskCache(new UnlimitedDiscCache(Environment.getExternalStorageDirectory()))
.memoryCacheSize(2 * 1024 * 1024)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.defaultDisplayImageOptions(options).build();
ImageLoader.getInstance().init(configs);
}
public void onCreate() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.ic_launcher).cacheInMemory(true)
.cacheOnDisk(true).displayer(new FadeInBitmapDisplayer(1500))
.build();
ImageLoaderConfiguration configs = new ImageLoaderConfiguration.Builder(
this).memoryCacheExtraOptions(480, 800)
.diskCache(new UnlimitedDiscCache(Environment.getExternalStorageDirectory()))
.memoryCacheSize(2 * 1024 * 1024)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.defaultDisplayImageOptions(options).build();
ImageLoader.getInstance().init(configs);
}
}
(备注:加入读写权限即可)
(权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
)