2012-02-03 37 views
0

我有一个屏幕,其中包含用户不可见的ImageView。用户将不得不从他们的图库浏览图片,我已经成功编码了。我用吐司来确保所选图像的路径正确,并将路径存储到字符串中。选择图像后,我的问题是,如何使用路径在ImageView上绘制所选图像? 它甚至有可能吗?Android:从SD卡上的已知路径将图像绘制到ImageView上

+0

嘿Matt_K请参阅此[链接](http://stackoverflow.com/questions/7304007/take-picture-from-camera-and-choose-from-gallery-and-display-in-image - 查看)和这[链接](http://stackoverflow.com/questions/7315498/how-to-store-and-retrieve-bitmap-in-sharedpreferences-in-android/7328685#7328685)。我希望它能解决你的问题。谢谢。 – anddev 2012-02-03 08:26:46

回答

2

尝试下面的代码来设置存储在SD卡中的文件的位图图像。

File imgFile = new File("/sdcard/Images/test_image.jpg"); 
if(imgFile.exists()){ 

    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); 

    ImageView myImage = (ImageView) findViewById(R.id.imageviewTest); 
    myImage.setImageBitmap(myBitmap); 

} 
+0

谢谢!有用 :) – DroidMatt 2012-02-03 12:57:37

相关问题