我使用UNIVERSAL IMAGE LOADER在Recyclerview中加载图片。
我试图通过ImageLoader.getInstance().displayImage("https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg", viewHolder.mImage, options);
它工作得很整齐,只有在提供一系列图像时才会出现问题。 有人请帮我解决这个问题。
在MainActivity中
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.threadPoolSize(5) // default
.threadPriority(Thread.NORM_PRIORITY - 3) // default
.denyCacheImageMultipleSizesInMemory()
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13) // default
.discCacheSize(50 * 1024 * 1024)
.discCacheFileCount(100)
.imageDownloader(new BaseImageDownloader(getApplicationContext())) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.writeDebugLogs()
.build();
ImageLoader.getInstance().init(config);
来自网络的图片。
public class data {
public static final String[] IMAGES = new String[]{
"https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg",
"https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg",
"https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg",
"https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg",
"https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg",
"https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg",
};
}
在onBindViewHolder
@Override
public void onBindViewHolder(final RecyclerViewHolder viewHolder, int i) {
// get the single element from the main array
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.mirlogo)
.showImageForEmptyUri(R.drawable.gallery_no_image)
.showImageOnFail(R.drawable.gallery_image_fail)
.cacheInMemory(false)
.cacheOnDisk(false)
.considerExifParams(false)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
ImageLoader.getInstance()
.displayImage(Arrays.toString(data.IMAGES), viewHolder.mImage, options);
}
Logcat错误。
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors D/ImageLoader: Load image from network [[https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg, https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg, https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg, https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg, https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg, https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg]_480x300]
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: UIL doesn't support scheme(protocol) by default [[https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg, https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg, https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg, https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg, https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg, https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg]]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: java.lang.UnsupportedOperationException: UIL doesn't support scheme(protocol) by default [[https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg, https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg, https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg, https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg, https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg, https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg]]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromOtherSource(BaseImageDownloader.java:280)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:99)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:98)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:74)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:265)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:238)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-10 10:21:29.453 26158-26344/com.example.root5solutions.mirrealtors E/ImageLoader: at java.lang.Thread.run(Thread.java:818)
12-10 10:21:29.453 26158-26158/com.example.root5solutions.mirrealtors W/Resources: Converting to string: TypedValue{t=0x5/d=0x1001 a=2 r=0x7f09000d}
12-10 10:21:29.453 26158-26158/com.example.root5solutions.mirrealtors W/Resources: Converting to string: TypedValue{t=0x5/d=0x1001 a=2 r=0x7f09000d}
12-10 10:21:29.463 26158-26158/com.example.root5solutions.mirrealtors W/Resources: Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0d00a6}
答案 0 :(得分:1)
你是根据它的位置得到一个阵列吗? 我想你错过了#34;职位"
data.Images[position];
使用ImageLoader.getInstance().displayImage(Arrays.toString(data.IMAGES[position]),viewHolder.mImage, options);