Java 为什么在Android的截击中找不到ImageLoader
我是Android的绝对初学者。现在,我开始使用volley进行Http请求和图像缓存。所以从这个链接下载volley.jar-。然后我把它放在libs库中。然后我按照教程创建了一个缓存类 我的图像缓存类Java 为什么在Android的截击中找不到ImageLoader,java,android,android-volley,Java,Android,Android Volley,我是Android的绝对初学者。现在,我开始使用volley进行Http请求和图像缓存。所以从这个链接下载volley.jar-。然后我把它放在libs库中。然后我按照教程创建了一个缓存类 我的图像缓存类 package com.example.newfeeds.volley; import com.android.volley.toolbox.ImageLoader.ImageCache; import android.graphics.Bitmap; import android.supp
package com.example.newfeeds.volley;
import com.android.volley.toolbox.ImageLoader.ImageCache;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
public class LruBitmapCache extends LruCache<String, Bitmap> implements
ImageCache {
public static int getDefaultLruCacheSize() {
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;
return cacheSize;
}
public LruBitmapCache() {
this(getDefaultLruCacheSize());
}
public LruBitmapCache(int sizeInKiloBytes) {
super(sizeInKiloBytes);
}
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight() / 1024;
}
@Override
public Bitmap getBitmap(String url) {
return get(url);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
put(url, bitmap);
}
}
package com.example.newfeeds.volley;
导入com.android.volley.toolbox.ImageLoader.ImageCache;
导入android.graphics.Bitmap;
导入android.support.v4.util.LruCache;
公共类LruBitmapCache扩展了LruCache实现
图像缓存{
公共静态int getDefaultLruCacheSize(){
final int maxMemory=(int)(Runtime.getRuntime().maxMemory()/1024);
最终int cacheSize=maxMemory/8;
返回缓存大小;
}
公共LRubitMacache(){
这个(getDefaultLruCacheSize());
}
公共lrubitMacache(int-sizeInKiloBytes){
超级(sizeInKiloBytes);
}
@凌驾
受保护的int-sizeOf(字符串键、位图值){
返回值.getRowBytes()*value.getHeight()/1024;
}
@凌驾
公共位图getBitmap(字符串url){
返回get(url);
}
@凌驾
公共位图(字符串url、位图){
put(url、位图);
}
}
但它一直说无法解析导入命名空间中的符号ImageLoader
我的项目结构截图如下
我遵循这个教程 我也面临着类似的问题。 只需将其粘贴到build.gradle应用程序模块中
compile 'com.android.volley:volley:1.0.0'
并同步您的项目。更新:
只需将其粘贴到build.gradle应用程序模块中
compile 'com.android.volley:volley:1.0.0'
implementation'com.android.volley:volley:1.1.0'
和同步您的项目。我复制粘贴了一个项目,我也遇到了同样的错误,我从build->rebuild project重建了我的项目,在使用“alt+enter”进行一些导入后,错误消失了。可能是
jar
文件的问题。尝试通过Gradle'而不是jar添加截取。截取:library:1.0.19'
它现在正在工作。我刚刚关闭了Android studio并再次打开它。它是如此的有线。