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())你能解釋一下這條線嗎 –

相關問題