How to programmatically set image to ImageView - MargaritaOstrovskaia/AndroidBasics---MusicalStructureApp GitHub Wiki

  • get name of image
  • create Drawable object
  • set this object in view
        // 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);