设置ImageView的显示图像中的SD卡?图像、ImageView、SD

由网友(抹不掉的奢華)分享简介:我有存储在我的手机的SD卡的图像。我想显示在一个图像视图。我知道文件的位置。在活动的OnCreate有一个简单的方法,这样说:ImageView的IMG =(ImageView的)findViewById(R.id.imageView1);。字符串路径= Environment.getExternalStorageD...

我有存储在我的手机的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);
 

希望这有助于。

imageview 设置图片

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.

阅读全文

相关推荐

最新文章