我正在尝试从服务器加载图像以在 ImageView 中显示它
我用了
ImageView imgView = (ImageView) findViewById(R.id.ivProduct);
Bitmap bitmap = null;
try {
URL urlImage = new URL(
"http://www.google.fr/intl/en_com/images/srpr/logo1w.png");
HttpURLConnection connection = (HttpURLConnection) urlImage
.openConnection();
InputStream inputStream = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
imgView.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}`
这很好,但是当我在服务器上下载相同的图像并将网址更改为
http://localhost:9527/market_helper/img_products/logo1w.png
它不起作用。问题是什么 ?