Is it possible to use Glide to download image to load into a TextView?

RedEagle picture RedEagle · Nov 8, 2015 · Viewed 8.7k times · Source

In my app I download an image from an URL and set it into an ImageView through Glide, however, I'm trying to remove a few unnecessary layouts, so is it possible to use Glide to download an image and set into to TextView?

try {
  Glide.with(holder.logo.getContext())
       .load(standingObjectItems.get(position).getImgId()).diskCacheStrategy(DiskCacheStrategy.ALL)
       .error(R.mipmap.ic_launcher)
       .placeholder(R.mipmap.ic_launcher)
       .into(holder.logo);

} catch (IllegalArgumentException | IndexOutOfBoundsException e) {
  e.printStackTrace();
}

Answer

RedEagle picture RedEagle · Nov 8, 2015
Glide.with(left.getContext())
     .load(((FixturesListObject) object).getHomeIcon())
     .asBitmap()
     .into(new SimpleTarget<Bitmap>(100,100) {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
          left.setCompoundDrawablesWithIntrinsicBounds(null, new BitmapDrawable(left.getResources(),resource), null, null);
        }
});