Reputation: 25
I have this simple structure
Now I should load 11.png
to ImageView from URI.
How do I do this?
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageURI(Uri.fromFile(new File("What should be here???")));
Upvotes: 1
Views: 65
Reputation: 2686
I think you Are New To Android?
Its Better To move the Image File to Drawable Folder and and Set Image View From the Drawable. You Can Use BatchDrawableImport Plugin in Android Studio to Import multiple Drawable Files
imageView = (ImageView)findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.yourImageName);
Or Move the File to Assets Folder and Using Assets Manager You Can Achieve the Solution
AssetManager manager = getAssets();
// Read a Bitmap from Assets
try {
InputStream open = manager.open("icon.png");
Bitmap bitmap = BitmapFactory.decodeStream(open);
ImageView view = (ImageView) findViewById(R.id.ImageView01);
view.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
Upvotes: 1