I need to display an image by specifying a file name, and not using a resource. For example, showImage("background.png")instead of showImage(R.drawable.background).
showImage("background.png")
showImage(R.drawable.background)
Does anyone know how?
Many thanks.
Read this Android Image Tutorial . Here is an example that uses FileOutputStream to record an image, I am sure FileInputStream too. Here's another example code that downloads images and converts them to an input stream that is decoded:
bmImg = BitmapFactory.decodeStream(is); imView.setImageBitmap(bmImg);
public static Bitmap decodeFile (String pathName, BitmapFactory.Options selects)
, , .
You can use the method below to get the image using its name from the resource folder.
public int getImage(String imageName) { return this.getResources().getIdentifier(imageName, "drawable", this.getPackageName()); }
Source: https://habr.com/ru/post/1703835/More articles:PHP Warning: Too many open files - any ideas? - linux"Killall -r -9." guaranteed to work? - linuxASP.Net & SessionState - asp.net-mvcQuestion about Java enumerations - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1703834/what-would-you-say-to-someone-who-wants-to-make-everything-a-net-control&usg=ALkJrhjiDDS4ks2JN-5QmvtZ3b0MPjxP3AHyper-V / WMI Programming Question - hyper-vDesign Question DAL - designOptimal way to check if query string is int? - c #Asp.net Self Hosted WSF Service WSDL with Relative Paths - wsdlIs this setter evil - oopAll Articles