所以我有一个类似rest API的东西,当我调用它时,它为我提供了带有Json对象的图像源。
我在服务器中有图像的src,但我不知道如何使用它们。

 rule_op1.setImageResource("https://admin.webeskan.com/upload/lawgroup/"+law0);


其中所有图像的“ https://admin.webeskan.com/upload/lawgroup/”相同,而law0是我从API(Json对象)获得的字符串之一

最佳答案

使用Glide可能会很有帮助。加载图像非常有效。

https://github.com/codepath/android_guides/wiki/Displaying-Images-with-the-Glide-Library

在您的应用gradle中添加以下依赖项。

  implementation 'com.github.bumptech.glide:glide:4.8.0'
  // Glide v4 uses this new annotation processor -- see https://bumptech.github.io/glide/doc/generatedapi.html
  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'


添加此行以加载图像

GlideApp.with(context)
    .load("https://admin.webeskan.com/upload/lawgroup/"+law0)
    .override(300, 200)
    .into(rule_op1);

09-04 22:57
查看更多