I have a screen that contains an ImageView which is not visible to user. User would have to browse for a picture from their Gallery, in which I have successfully coded. I've used toast to ensure that the path to the Image selected is correct and have stored the path to a string. My problem is after selecting the image, how can I draw the selected image on the ImageView by using the path? Is it even possible?
Try the below code to set Bitmap images from a file stored inside a SD-Card.
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.