2015-11-08 58 views
3

在我的应用程序中,我从URL下载图像并通过Glide将其设置为ImageView,但是,我试图删除一些不必要的布局,因此可以使用Glide下载图像并将其设置为TextView ?是否可以使用Glide下载图像以加载到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(); 
} 
+0

你会如何设置'Bitmap'的'ImageView'? – Emmanuel

+0

你可以做到。 –

+0

@tinysunlight怎么样? – RedEagle

回答

16
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); 
     } 
}); 
+0

谢谢!我试图实现同样的事情,现在我可以:) – Pangu

+0

谢谢。对我来说非常有用 – hungtdo

+0

加载(((FixturesListObject)对象).getHomeIcon())你能解释一下这条线吗 –

相关问题