如何将json图像url字符串转换为位图图像以在android应用程序中显示图像


How to convert the json image url string into Bitmap image to display images in android application

我正在开发一个android应用程序,因为我想从服务器数据库获取图像。我使用json从服务器数据库获取图像到android应用程序(图像文件夹在文件系统中)。但是当我在我的android应用程序中使用getimage .php链接时,我看不到图像。它说字符串(图像的url)不能转换为位图。建议我下一步怎么做。任何帮助都是感激的。谢谢你

使用VolleyImageRequest,通过JSON图像URL更新您的ImageView。

ImageRequest imageRequest = new ImageRequest(image_url_coming_from_json, new Response.Listener<Bitmap>() {
            @Override
            public void onResponse(final Bitmap response) {
                        your_imageView.setImageBitmap(response);
            }
        }, 0, 0, ImageView.ScaleType.CENTER_INSIDE, null, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(your_activity.this, error.toString(), Toast.LENGTH_LONG).show();
            }
        });
        RequestQueue requestQueue = Volley.newRequestQueue(your_activity.this);
        requestQueue.add(imageRequest);

使用NetworkImageView代替ImageView