I am getting file path of image by using browse button....after that I want to set this image to an image view using the file path
src: src is an attribute used to set a source file or you can say image in your imageview to make your layout attractive. Below is the example code in which we set the source of a imageview lion which is saved in drawable folder.
ImageView imgView = new ImageView(this); imgView. setBackgroundResource(R. drawable. img1);
If with File
you mean a File
object, I would try:
File file = ....
Uri uri = Uri.fromFile(file);
imageView.setImageURI(uri);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With