ImageView.setImageUri only works for local Uri, ie a reference to a local disk file, not a URL to an image on the network.
Here is an example of how to fetch a Bitmap from the network.
private Bitmap getImageBitmap(String url) {
Bitmap bm = null;
try {
URL aURL = new URL(url);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
} catch (IOException e) {
Log.e(TAG, "Error getting bitmap", e);
}
return bm;
}
Once you have the Bitmap from getImageBitmap(), use: imgView.setImageBitmap(bm);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…