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
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
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
0 Response to "How to load an image from a file and set on an ImageView"
Post a Comment