在路径和通用图像加载器空间机器人加载本地图像 [英] Android loading local image with space in path and with universal image loader

查看:172
本文介绍了在路径和通用图像加载器空间机器人加载本地图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发中,我要与通用图像加载器的帮助下显示本地图像android应用。但是,当我尝试显示的图像具有的空间在里面的本地图片路径则无法显示图像。我试图在下列方式:

I am developing android application in which I want to display local image with the help of universal image loader. But when I try to display image which has space in it's local image path then it not able to display image. I tried it in following manner:

Uri.fromFile(new File(newImagePath)).toString();

我收到以下错误:

I am getting following error:

java.io.FileNotFoundException: /storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20150421-WA0002.jpg: open failed: ENOENT (No such file or directory)
        at libcore.io.IoBridge.open(IoBridge.java:456)

如果试图加载图像,在其本地路径没有空格那么它工作正常,但图像空间,其路径造成的问题。需要一些帮助。谢谢你。

If tried to load image which has no space in its local path then it works fine but image with space in its path cause issue. Need some help. Thank you.

推荐答案

其实它的问题与通用图像加载器。 https://github.com/nostra13/Android-Universal-Image-Loader /问题/ 371

Actually its problem with universal image loader. https://github.com/nostra13/Android-Universal-Image-Loader/issues/371

所以,你就必须去code图像路径中除去空间。

So you just have decode your image path to remove space.

按照上面的链接讨论中,我得到了解决:

As per discussion in above link I got the solution :

final String uri = Uri.fromFile(file).toString();
final String decoded = Uri.decode(uri);

ImageLoader.getInstance().displayImage(decoded, imageView);

这篇关于在路径和通用图像加载器空间机器人加载本地图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆