直接放完整干货源码:
https://wwpm.lanzouj.com/iMfkJ19l318j
断更很久了,支持的给个金币吧
java{
final ImageView imageView = (ImageView) findViewById(R.id.tx1);
new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL("https://pythonjishu.com/wp-content/uploads/2023/07/python-logo.jpg");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
final Bitmap bitmap = BitmapFactory.decodeStream(input);
input.close();
runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
代码如上
导入库 android.widget.ImageView
评论