如何访问和显示来自 API (URL) 的图像?

How to access and show an image from an API (URL)?

我正在尝试使用此 URL:“https://pixabay.com/api/?key=14291199-65ce36d5f7ccc529de84c3b84”访问 pixabay 图片。 我在处理来自 URL 的 json 数据和显示图像时遇到问题。我要做的是访问 API URL 图像并将它们显示为一组相邻显示的图像。

使用类似的东西:

Rest.get("https://pixabay.com/api/").
     jsonContent().
     queryParam("key", MY_API_KEY).
     fetchAsJsonMap(response -> {
         Map data = response.getResponseData();
         List<String, Map> hits = (List<String, Map>)data.get("hits");
         for(Map hit : hits) {
             String url = (String)hit.get("previewURL");
             addPreviewURL(url);
         }
     });

你还可以使用更强大的属性https://www.codenameone.com/blog/properties-are-amazing.html