Skip to content

How to programmatically set image to ImageView

Margarita Ostrovskaia edited this page May 5, 2020 · 2 revisions
        // set Artist image
        String name = artist.getTitle().replaceAll(" ", "_").toLowerCase();
        Drawable drawable = context.getDrawable(context.getResources().getIdentifier(name, context.getString(R.string.def_type),
                context.getPackageName()));
        holder.imageView.setImageDrawable(drawable);

Clone this wiki locally