把网络图片转换为bitmap并显示在ImageView中 傷城~ 2022-08-27 14:40 124阅读 0赞 1.把网络图片转换成Bitmap public static Bitmap getImage(String path) throws Exception{ URL url = new URL(path); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream is = conn.getInputStream(); return BitmapFactory.decodeStream(is); } 2.把bitmap显示在ImageView中 首先用findViewById找到ImageView 然后, mImageView.setImageBitmap(bitmap);
还没有评论,来说两句吧...