ImageLoader的使用

来源:互联网 发布:深入理解大数据 pdf 编辑:程序博客网 时间:2024/06/14 22:52

1、导包

compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
2、在适配器里面进行编辑(写在构造方法里面)

 //创建默认的ImageLoader配置参数
        ImageLoaderConfiguration configuration = ImageLoaderConfiguration
                .createDefault(context);

        //将configuration配置到imageloader中
       ImageLoader imageLoader=ImageLoader.getInstance();
        imageLoader.init(configuration);

       DisplayImageOptions options=new DisplayImageOptions.Builder()
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .showImageOnLoading(R.mipmap.ic_launcher)
                .showImageForEmptyUri(R.mipmap.ic_launcher)
                .showImageOnFail(R.mipmap.ic_launcher)
                .build();


/** * url 图片连接 * imageview  图片地址 */imageLoader.displayImage(url,imageView,options);

原创粉丝点击