Put resources in drawable
ImageView imgView=new ImageView(this);
imgView.setBackgroundResource(R.drawable.img1);
I set it up in imageView like this. Instead of registering resources in the drawable folder, I want to set the imageView by giving the path of the file. How shall I do it?
android imageview android-imageview android-file
If you want to receive the path of the image from SD-Card and register it in ImageView, Using Bitmap
File imgFile = new File("/sdcard/Images/test_image.jpg");
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
myImage.setImageBitmap(myBitmap);
}
You can do it like this.
Of course, in the Android manifest file,
<uses-permission android:name="android.permission.You must register WRITE_EXTERNAL_STORAGE" />
565 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
566 Who developed the "avformat-59.dll" that comes with FFmpeg?
593 Uncaught (inpromise) Error on Electron: An object could not be cloned
867 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.