设置 Imageview 以在 sdcard 中显示图像? [英] Set Imageview to show image in sdcard?

查看:26
本文介绍了设置 Imageview 以在 sdcard 中显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在手机的 SD 卡中存储了一张图片.我想在图像视图中显示它.我知道文件的位置.在活动的 oncreate 上有一种简单的方法可以说

I have a image stored in SD card of my phone. I want to show it in a image view. I know the location of the file. On the oncreate of the activity is there a simple way to say something like

ImageView img = (ImageView) findViewById(R.id.imageView1);    
String path = Environment.getExternalStorageDirectory().toString() "Images/image.jpg";     
img.setsrc = path ;

如果有任何方法可以做到这一点,请告诉我.谢谢.

Please let me know if there is any way to do this. Thank you.

推荐答案

Bitmap bmp = BitmapFactory.decodeFile(pathName);
ImageView img;
img.setImageBitmap(bmp);

希望这会有所帮助.

这篇关于设置 Imageview 以在 sdcard 中显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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