【问题标题】:Why ImageLoader cannot be found in volley in Android为什么在 Android 的 volley 中找不到 ImageLoader
【发布时间】:2016-01-20 11:36:01
【问题描述】:

我是 Android 的绝对初学者。现在我开始使用 volley 进行 Http 请求和图像缓存。所以从这个链接下载 volley.jar - http://api.androidhive.info/volley/volley.jar 。然后我把它放在 libs 库中。然后我按照教程创建了一个缓存类。

我的图片缓存类

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);
    }
}

但它一直说无法在导入命名空间中解析符号 ImageLoader。

我的项目结构截图如下。

我正在学习本教程。 http://www.androidhive.info/2014/06/android-facebook-like-custom-listview-feed-using-volley/

【问题讨论】:

  • 可能是jar 文件的问题。尝试通过Gradle' instead of jar compilecom.mcxiaoke.volley:library:1.0.19'添加截击
  • 它现在正在工作。我刚刚关闭了 Android Studio 并再次打开它。它是如此有线。

标签: java android android-volley


【解决方案1】:

我遇到了类似的问题。 只需将其粘贴到您的 build.gradle 应用模块中

compile 'com.android.volley:volley:1.0.0'

并同步您的项目。

【讨论】:

    【解决方案2】:

    更新: 只需将其粘贴到您的 build.gradle 应用模块中

    implementation 'com.android.volley:volley:1.1.0'

    并同步您的项目。

    【讨论】:

      【解决方案3】:

      我复制粘贴了一个项目,我也遇到了同样的错误,我从 build -> rebuild project 重建了我的项目,在使用“alt+enter”进行一些导入后,错误消失了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-30
        • 1970-01-01
        • 2021-07-27
        • 2013-08-20
        • 2010-10-25
        • 2016-12-15
        • 2014-10-28
        • 1970-01-01
        相关资源
        最近更新 更多