Android: ImageLoader must be init with configuration before using
来源:互联网 发布:图160战略轰炸机 知乎 编辑:程序博客网 时间:2024/05/21 11:20
在使用ImageLoader来显示网络传回的图片的时候,报错 ImageLoader must be init with configuration before using ,网上找的方法是加一句
imageLoader.init(ImageLoaderConfiguration.createDefault(MainActivity.this));
一开始以为是笔误,把imgeLoader写成了小写, 所以改成大写ImageLoader就直接加上去。如果这么加,又会有问题,不能对一个非静态方法做静态引用,也就是这个imageLoader是一个对象才对,那么就试着new一个,结果构造方法又是不可见的。所以,网上这些人抄袭别人的东西,又总是只写一半,浪费别人时间又误导别人。
前面说了,ImageLoader的init()方法是一个非静态方法,要调用就得有一个对象,而构造方法不可见,那么一般会有一个getInstance()方法让我们获取对象。
加一句下面的代码:
ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(HomeActivity.homeContext));
HomeActivity.homeContext是一个context,这里根据自己需要改成自己的context.
另外,最上面给出的那行代码也是没有错的,只是没有交代清楚,实际上他们是定义了一个BaseActivity作为他么Activity的父类,在BaseActivity中有这么一行代码
public ImageLoader imageLoader = ImageLoader.getInstance();
所以是小写的imgeLoader
0 0
- Android: ImageLoader must be init with configuration before using
- ImageLoader must be init with configuration before using
- ImageLoader must be init with configuration before using 错误解决方法
- ImageLoader must be init with configuration before using 错误解决方法
- ImageLoader must be init with configuration before using 错误解决方法
- ImageLoader must be init with configuration before using 错误解决方法
- ImageLoader must be init with configuration before using 错误解决方法
- ImageLoader must be init with configuration before using
- ImageLoader must be init with configuration before using 错误解决方法
- 解决ImageLoader must be init with configuration before using
- ImageLoader must be init with configuration before using
- ImageLoader must be init with configuration before using
- 关于ImageLoader must be init with configuration before using问题解决
- Android ImageLoader must be init with configuration before using 错误解决方法
- Android ImageLoader must be init with configuration before using 错误解决方法
- 开源项目Universal Image Loader :ImageLoader must be init with configuration before using
- 图片异步加载报错ImageLoader must be init with configuration before using
- java.lang.RuntimeException: ImageLoader must be init with configuration before using的解决方法
- linux之proc目录初识
- Java中Synchronized和Lock的使用和区别
- kotlin第一次运行在Android上
- JSON讲解
- 【Android Exception】android.content.pm.PackageManager$NameNotFoundException
- Android: ImageLoader must be init with configuration before using
- js弹窗总结
- 设计模式(二)单件模式Singleton(创建型)
- 修改tomcat的端口号
- 如何才能写出一篇好的技术文章
- lsof的用法
- 远程磁盘映射
- IOS(UI)_CGContextRef(绘画)
- Android Studio 快捷键