80,490
社区成员
发帖
与我相关
我的任务
分享
try {
URL url = new URL(path); //path图片的网络地址
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
if(httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK){
Bitmap bitmap = BitmapFactory.decodeStream(httpURLConnection.getInputStream());
imageview.setImageBitmap(bitmap);//加载到ImageView上
System.out.println("加载网络图片完成");
}else{
System.out.println("加载网络图片失败");
}
} catch (IOException e) {
e.printStackTrace();
} 这是一个简单的加载网络图片的方法,还有好多方法,可以百度。