1

I'm using the glide Library to load images and I made a method that goes like this:

void alterarInformacoes(ImageView slotImagem, String image) {
        Glide.with(this)
                .load(R.drawable.image)
                .into(slotImagem);
    }

But it doesn't work, I'd like to know if there's a way to use a string with the name of the drawable so that I can use a function to dynamically set the images.

1 Answers1

1

You can get int value of drawable resource by name with this code:

int drawableResourceId = this.getResources().getIdentifier("nameOfDrawable", "drawable", this.getPackageName());