2016-06-15 35 views
0

我想設置圖像屬性的值對象類,你會在下面,但使用滑翔滑翔與setter方法URL圖像源

try { 
InputStream stream = new URL("my url").openStream(); 
Bitmap pictureBitmap = BitmapFactory.decodeStream(stream); 
"my model class".setImageBitmap(pictureBitmap); 
} catch (IOException e) { 
      e.printStackTrace();; 
     } 

我想這是你如何獲取從圖像利用Glide作爲位圖

Glide 
    .with(getContext()) 
    .load("my url") 
    .asBitmap().... 
+0

那麼,你的問題到底是什麼? – ikhsan

+0

@ikhsan使用Glide完成代碼設置圖像屬性 – Geob

+0

檢查我的答案 – ikhsan

回答

0

網址源可以在使用SimpleTarget作爲參數傳入方法。它會加載你的位圖,你可以在圖像準備好後將它放入你的圖像模型中。

Glide 
.with(getApplicationContext()) 
.load(IMAGE_URL) 
.asBitmap() 
.into(new SimpleTarget<Bitmap>(100,100) { 
    @Override 
    public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { 
     YourModelClass.setImageBitmap(resource); 
    } 
}); 
+0

非常感謝@ikhsan – Geob

+0

@Geob如果它解決了您的問題,請接受答案。 – ikhsan