[英]Android Volley imageloader with % progress while downloading images
[英]Why ImageLoader cannot be found in volley in Android
我絕對是 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/
我面臨着類似的問題。 只需將其粘貼到您的 build.gradle 應用程序模塊中
compile 'com.android.volley:volley:1.0.0'
並同步您的項目。
更新:只需將其粘貼到您的 build.gradle 應用程序模塊中
implementation 'com.android.volley:volley:1.1.0'
並同步您的項目。
我復制粘貼了一個項目,我也遇到了同樣的錯誤,我從 build -> 重建項目重建了我的項目,在使用“alt+enter”做了一些導入后,錯誤消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.