tags:

views:

51

answers:

1

Hello - I have an image that is currently stored in variable of type "File"..

File img = ...;

What is the easiest way to display this image onto the screen so I can verify it is working correct?

Thanks!

A: 

If you have an ImageView in your layout, you can do something like this, assuming you have a reference to your ImageView named view:

Drawable d = Drawable.createFromPath(img);
image.setImageDrawable(d);
synic
Seems simple enough, except I am getting an error that createFromPath requires an argument of type String instead of type File.. Is it expecting the path of the file? I attempted to try img.getAbsolutePath() but it crashed.
Tyler
getAbsolutePath should work. What was the error?
synic
:) Nevermind, I figured out that I had a whole different problem.. My img variable is not getting initialized correctly.Thanks!
Tyler