how to set image dynamically in android

Solutions on MaxInterview for how to set image dynamically in android by the best coders in the world

showing results for - "how to set image dynamically in android"
Bertram
26 Jan 2017
1String uri = "@drawable/myresource";  // where myresource (without the extension) is the file
2
3int imageResource = getResources().getIdentifier(uri, null, getPackageName());
4
5imageview= (ImageView)findViewById(R.id.imageView);
6Drawable res = getResources().getDrawable(imageResource);
7imageView.setImageDrawable(res);
Adrien
02 Oct 2020
1String fnm = "cat"; //  this is image file name
2String PACKAGE_NAME = getApplicationContext().getPackageName();
3int imgId = getResources().getIdentifier(PACKAGE_NAME+":drawable/"+fnm , null, null);
4System.out.println("IMG ID :: "+imgId);
5System.out.println("PACKAGE_NAME :: "+PACKAGE_NAME);
6//    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),imgId);
7your_image_view.setImageBitmap(BitmapFactory.decodeResource(getResources(),imgId));
queries leading to this page
set image from drawable in imageview androidif we want to set dynamic image in image view so how can we fix itimageview set image from drawableandroid set image resource dynamichow to set image in imageview in android studio dynamicallydynamically change image in imageview androidandroid studio change drawable imagehow to save add drawable image to imageview from a string variablehow to set drawable to imageview in android programmaticallyset image drawable programmatically androidandroid java change image dynamicallychange image view drawable programmaticallyhow to change image resource by using setresource method in androidandroid imageview set image from drawable programmaticallyhow to change drawable image programmatically in androidandroid studio setimageresource darawblehow to add a dynamic image android studioset string image in image resourceset drawable in imageview androidchange image dynamically in android studiohow to change image from drawable 24 to drawableandroid set imageview src programmaticallyset image resource dynamicallyimageview iimagedrawable programmaticallyset drawable image programmatically androidkotlin how to get drawable image to display in imageview using its nameandroid java update image dynamicallyandroid imageview set drawableandroid studio imageview getresourcesset tit of image programmatically androidimagevies set drawablehow to set image from drwaeable in javacodehow to set image dynamically in androidload image dynamically android set image from drawable androidhow to dynamically set image resource in kotlinhow to dynamically load an image in androidandroid imageview get drawable namehow to set image drawable in name of stringmake dynamic image androiddynamically access image in android studioadd image dynamically in androidset image from drawable in androidimageview set drawableandroid dynamic imgehow to change image dynamically in androidandroid create dynamic imagesandroid set image resource dynamic recyclerviewdrawable image show imageview programmaticallyset drawable to imageview programmatically androidchange integer image resource to drawable apiset image drawable androidkotlin set image resource with nameset string image in imageresourceandroid set dynamic imageandroid studio change imageview drawable programmaticallyandroid set imageview drawable programmaticallyhow to load an image from drawable in android imageviewandroid dynamic imageset imageview from drawable programmaticallyshow drawable image form programmatically androidsetimageresource android drawableset drawable image to imageview androidload a image from drawable to imageview programmaticallyhow to set drawable image programmatically in androidkotlin how to save add drawable image to imageview from a string variableimageview set drawable programmaticallyset drawable to imageviewhow to dynamically add images in android studiodynamic drawable androidhow to set drawable imageviewset imageview to drawableandroid set imageview drawable set image dynamically in androidandroid java recyclerview display r drawable dynamically by creation valuechange imageview drawable programmaticallyhow to set drawable to imageview programmaticallyhow to set image dynamically in android