Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an image to imageView using filepath in android

Tags:

android

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

like image 760
Manikanta Ottiprolu Avatar asked Apr 04 '13 14:04

Manikanta Ottiprolu


People also ask

Which attribute is used to set an image in ImageView in android?

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.

How do I get the file path of a picture?

ImageView imgView = new ImageView(this); imgView. setBackgroundResource(R. drawable. img1);


1 Answers

If with File you mean a File object, I would try:

File file = ....
Uri uri = Uri.fromFile(file);
imageView.setImageURI(uri);
like image 102
rciovati Avatar answered Oct 10 '22 03:10

rciovati