设置ImageView的显示图像中的SD卡? [英] Set Imageview to show image in sdcard?

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

问题描述

我有存储在我的手机的SD卡的图像。我想显示在一个图像视图。我知道文件的位置。在活动的OnCreate有一个简单的方法,这样说:

  ImageView的IMG =(ImageView的)findViewById(R.id.imageView1);
。字符串路径= Environment.getExternalStorageDirectory()的toString()图像/ image.jpg的;
img.setsrc =路径;
 

请让我知道,如果有任何的方式来做到这一点。谢谢你。

解决方案

  BMP位= BitmapFactory.de codeFILE(将pathName);
ImageView的IMG;
img.setImageBitmap(BMP);
 

希望这有助于。

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);

Hope this helps.

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

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