我对图片有意见。我在picture=sites/default/files/arrow_green_right_0.png里有一张照片。在我的应用程序中,我只得到这个字符串。我想在我的imageView中显示这个字符串中的图片。我怎么能做到这一点?
发布于 2012-06-04 14:17:42
试试这个:
ImageView img = new ImageView(this);
File file = new File(YOUR PATH TO THE IMAGE);
if (file.exists()) {
img.setImageURI(Uri.fromFile(file));
}发布于 2012-06-04 14:14:15
您好,您必须首先设置图像的路径,并确保您处理它的异常,以避免它崩溃。遵循以下代码:
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);
}https://stackoverflow.com/questions/10876958
复制相似问题