Android 从字符串到图像的转换

Android 从字符串到图像的转换,android,android-imageview,Android,Android Imageview,可能重复: 这里图像路径存储为字符串我想将字符串转换为图像,需要在emulator中查看图像这是怎么可能的?请告诉我 谢谢使用并添加字符串作为资源 Bitmap bm = BitmapFactory.decodeFile(mImagePath); ImageView image = (ImageView) findViewById(R.id.image_view); image.setImageBitmap(bm); 假设mImagePath是包含路径的字符串,而R.id.image\u v

可能重复:

这里图像路径存储为字符串我想将字符串转换为图像,需要在emulator中查看图像这是怎么可能的?请告诉我

谢谢

使用并添加字符串作为资源

Bitmap bm = BitmapFactory.decodeFile(mImagePath);
ImageView image = (ImageView) findViewById(R.id.image_view);
image.setImageBitmap(bm);
假设
mImagePath
是包含路径的字符串,而
R.id.image\u view
是布局中图像视图的id

祝你好运

这可能会有帮助。根据这一回答:

File imgFile = new  File(“/sdcard/Images/test_image.jpg”);
if(imgFile.exists()){
    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile);
    ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
    myImage.setImageBitmap(myBitmap);
}
重复: