Universal-Image-Loader使用小记
来源:互联网 发布:深圳盘古数据上市了没 编辑:程序博客网 时间:2024/05/25 08:13
1.Android Studio下导入:
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
2.新建App类继承Application类
3.AndroidMainfest配置,Application节点下添加:
android:name=".App"
private void initUniversalImageLoader() { ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .threadPriority(Thread.NORM_PRIORITY - 2)//设置线程优先级 .threadPoolSize(4)//线程池内加载的数量,推荐范围1-5内。 .denyCacheImageMultipleSizesInMemory()//当同一个Uri获取不同大小的图片缓存到内存中时只缓存一个。不设置的话默认会缓存多个不同大小的图片 .memoryCacheExtraOptions(480, 800)//内存缓存文件的最大长度 .memoryCache(new LruMemoryCache(10 * 1024 * 1024))//内存缓存方式,这里可以换成自己的内存缓存实现。(推荐LruMemoryCache,道理自己懂的) .memoryCacheSize(10 * 1024 * 1024)//内存缓存的最大值 .diskCache(new UnlimitedDiskCache(FileUtils.createImageCacheSavePath(context)))//可以自定义缓存路径 .diskCacheFileNameGenerator(new Md5FileNameGenerator())//对保存的URL进行加密保存 .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .imageDownloader(new BaseImageDownloader(getApplicationContext(), 5 * 1000, 30 * 1000))//设置连接时间5s,超时时间30s .writeDebugLogs() .build(); ImageLoader.getInstance().init(configuration); }
5.在App的onCreate()方法中添加initUniversalImageLoader()方法
6.配置完毕
0 0
- Universal-Image-Loader使用小记
- Universal-Image-Loader 使用
- Android Universal Image Loader 使用
- 初步使用universal-image-loader
- universal-image-loader 使用思路
- Universal Image Loader使用文档
- Universal-Image-Loader的使用
- Android-Universal-Image-Loader 使用
- Universal-Image-Loader 使用详解
- universal-image-loader简单使用
- Universal-Image-Loader的使用
- Universal-Image-Loader的使用
- universal-image-loader使用参考
- Universal-Image-Loader使用(一)
- Android Universal-Image-Loader使用
- Android-Universal-Image-Loader使用
- android-universal-image-loader的使用
- Universal–Image–Loader 使用
- 字符串匹配——Sunday算法
- Css3 - Animation Examples
- iOS-CoreGraphics学习(彩色图片转灰白图片)
- 经典电影
- Apache与Tomcat有什么关系和区别
- Universal-Image-Loader使用小记
- 本科毕业生活感悟
- 基于DotSpatial实现面积测量图层
- JAVA自学之每日一题(七)
- 欢迎使用CSDN-markdown编辑器
- Android GPS坐标距离计算
- 235. Lowest Common Ancestor of a Binary Search Tree
- Robert 的军队
- 一个简易的视屏播放器