2016-06-15 56 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