package com.example.myapplication3;
import android.app.Application;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.io.File;
public class ImageLoderUtils extends Application {
@Override
public void onCreate() {
super.onCreate();
ImageLoaderConfiguration aDefault =new ImageLoaderConfiguration.Builder(this)
.diskCache(new UnlimitedDiskCache(new File(getCacheDir(),"image")))
.build();
ImageLoader.getInstance().init(aDefault);
}
适配器
public class MyAdapter2 extends BaseAdapter {
Context context;
List<Bean.DataBean> list;
private ImageLoader imageLoader=ImageLoader.getInstance();
private final DisplayImageOptions builder;
public MyAdapter2(Context context,List<Bean.DataBean> list) {
this.context=context;
this.list=list;
builder = new DisplayImageOptions.Builder()
.cacheOnDisk(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.showImageForEmptyUri(R.mipmap.ic_launcher)
.cacheInMemory(true)
.build();
}
}
缓存目录
最新推荐文章于 2024-07-17 16:25:15 发布