android:webservice image替换为Local文件夹中的图像

and*_*oid 0 android web-services image

我正在进入android的聊天应用程序的最后阶段.

在处理图像和Web服务时,我遇到的问题很少.

因此,当我选择图像并将该图像发送到Web服务时,我从服务获取URL.如何将该网址转换为我本地文件夹中的图像.我很困惑,我怎么能让这个工作.

我想在列表视图中显示所选图像以及从Web服务返回的消息.

请指导我这个问题.有没有其他选择来解决这个问题.

谢谢.

Moh*_*rma 5

使用此方法:

public static Bitmap getBitmapFromURL(String src) {
        try {
            URL url = new URL(src);
            HttpURLConnection connection = (HttpURLConnection) url
            .openConnection();
            connection.setDoInput(true);
            connection.connect();
            connection.setReadTimeout(120000);
            InputStream input = connection.getInputStream();
            Bitmap myBitmap = BitmapFactory.decodeStream(input);
            return myBitmap;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
Run Code Online (Sandbox Code Playgroud)

这里你需要将图像的URL传递给函数,你可以将图像设置为setImageBitmap函数.