imageloader框架

public class App extends Application {
    //:注册 Application
    @Override
    public void onCreate() {
        super.onCreate();
        //:设置框架的一些属性,然后初始化  ImageLoader
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                // 正在加载时显示的占位图
                .showImageOnLoading(R.mipmap.zhan)
//                // URL为空时显示的占位图
//                .showImageForEmptyUri(R.mipmap.zhaobudao)
                // 加载失败时显示的占位图
                .showImageOnFail(R.mipmap.shibai)

//                //可在实现中对 bitmap 做一些额外处理,比如加圆角、动画效果。
//                .displayer(new SimpleBitmapDisplayer())
                // bitmap的质量,默认为ARGB_8888
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .build();
        //构建
        ImageLoaderConfiguration loaderConfiguration = new ImageLoaderConfiguration.Builder(this)
                //把我们写的设置添加到构建中
                .defaultDisplayImageOptions(options)
                //构建
                .build();

        //获得实例
        ImageLoader imageLoader = ImageLoader.getInstance();

        //初始化
        imageLoader.init(loaderConfiguration);

//初始化完成后进入适配器加载图片

    }
}

猜你喜欢

转载自blog.csdn.net/qq_43413640/article/details/85332268
今日推荐