I would like to show something similar to a progressbar by using different images, for example an empty lawn if progress = 0 and a nearly complete house if progress = 95.
I have 30 files named image1.jpg …. image30.jpg
Would it be possible to set the Drawable of an ImageView by using a string for the file name? That way I could just get an int between 1 and 30 from the progress and add that to a string that I use to set the Drawable.
I have read this:
Android: Imageview showing an image according to edittext option
but I don’t want to write code for every case as I would like to use this function at different places of a project.
I would be very grateful for any help, either on how I can use strings and filenames for the Drawable or if there is another way of solving this.
Best regards,
Emil
You can retrieve the id if you know the name of the resources and then set the image via the id you determined earlier