How to load an image from a file and set on an ImageView

How to load an image from a file and set on an ImageView - Hello friend inabnomaniiyaha, In the article that you read this time with the title How to load an image from a file and set on an ImageView, we have prepared this article well for you to read and take information in it. hopefully the contents of the post Artikel Android,what we write you can understand. Alright, happy reading.

Judul : How to load an image from a file and set on an ImageView
link : How to load an image from a file and set on an ImageView

Baca juga


How to load an image from a file and set on an ImageView

 If you’re working with an Android application, this source code works as a way to load an image from a file:

Bitmap bitmap = BitmapFactory.decodeFile(pathToPicture);

The Bitmap and BitmapFactory classes are located in the android.graphics package:

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

Assuming that your pathToPicture is correct, you can then add this bitmap image to an ImageView like this:

ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView);

imageView.setImageBitmap(BitmapFactory.decodeFile(pathToPicture));

As shown, the setImageBitmap method is another key to this solution.

I’m currently using this approach to let users choose an image from their image/photo gallery, which is where I get the file path.



That's the articleHow to load an image from a file and set on an ImageView

That's it for the article How to load an image from a file and set on an ImageView this time, hopefully can be useful for all of you. well, see you in another article post.

You are now reading the articleHow to load an image from a file and set on an ImageView with link addresshttps://inabnonapudyawanabing.blogspot.com/2020/11/how-to-load-image-from-file-and-set-on.html

Related Posts :

0 Response to "How to load an image from a file and set on an ImageView"

Post a Comment

Tips Tricks for Android Phone

Tips & Tricks for Android Phone is a free android app and Collection of Tips and Tricks related to using your android mobile device lik...