java.lang.IllegalArgumentException:毕加索中的路径不能为空 [英] java.lang.IllegalArgumentException: Path must not be empty in Picasso
问题描述
我正在使用Picasso从mysql DB加载图像到自定义listview中.当直接传递URL时,图像正在加载,但是当我将URL分配给字符串并传递它时,它将引发异常,表示Path不能为空.
I am loading image from mysql DB using Picasso into custom listview. The image is loading when the URL is passed directly but when i assign the URL to string and pass it then it throws exception saying Path must not be empty.
String imageStringUrl = md.Image;
图像字符串包含 http://example.com/image.jpg
我正在通过毕加索,如下所示.
I am passing in Picasso like below.
Picasso.get()
.load(imageStringUrl)
.into(iview);
当我这样传递时,我得到了java.lang.IllegalArgumentException:路径不能为空.我已经尝试过如下所示的上述步骤,但是图像未加载.
When I pass like this I am getting java.lang.IllegalArgumentException: Path must not be empty. I have tried the above step like below but the image is not loading.
Picasso.get()
.load(new File(imageStringUrl))
.into(iview);
以上声明有什么问题?
推荐答案
我遇到了类似的问题.只需检查您的URL字符串是否为空即可.如果为空,则提供默认图像或从URL加载.希望这会有所帮助.
I had a similar problem. Just check if your URL string is empty or not. if it is empty give the default image or load from URL. Hope this helps.
if (image.isEmpty()) {
iview.setImageResource(R.drawable.placeholder);
} else{
Picasso.get().load(image).into(iview);
}
这篇关于java.lang.IllegalArgumentException:毕加索中的路径不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!