//創建自己的Application,然後繼承Application
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 configuration = new ImageLoaderConfiguration.Builder(this)
//把我們寫的設置添加到構建中
.defaultDisplayImageOptions(options)
//構建
.build();
//獲得實例
ImageLoader imageLoader = ImageLoader.getInstance();
//初始化,初始化完成後進入適配器加載圖片
imageLoader.init(configuration);
}
}
資訊_imageloader框架
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.