机器人:从SD卡与毕加索负荷图像 [英] android:load image from sdcard with picasso

查看:183
本文介绍了机器人:从SD卡与毕加索负荷图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有可能使用毕加索库从SD卡到ImageView的加载图像?

is it possible to use picasso library to load image from sdcard to imageView ?

推荐答案

毕加索文档提供,

资源,资产,档案,内容提供商都支持作为
  图像源。

Resources, assets, files, content providers are all supported as image sources.

您可以简单地做喜欢

String filename = "YOURIMAGE.png";
String path = "/mnt/sdcard/" + filename;
Picasso.with(context).load(new File(path)).into(imageView);

修改

由于@Budius建议,更好的方式,从磁盘路径访问文件,使用环境类。

As @Budius suggested, the better way to access file from disk path, use Enviroment class.

String filename = "YOURIMAGE.png";
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
Picasso.with(context).load(new File(baseDir + File.separator + filename)).into(imageView);

希望这会为你工作。

Hope it will work for you.

这篇关于机器人:从SD卡与毕加索负荷图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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