使用HttpURLConnection访问网络——加载网络图片

本文通过实验介绍了如何在Android应用中使用HttpURLConnection请求网络图片,并将其展示在界面上。首先,创建了一个包名为cn.edu.bzu.imageviewdemo的项目,设计了用户界面。然后,在MainActivity中编写代码,请求指定URL的图片并加载到应用中。
摘要由CSDN通过智能技术生成

一.
实验目的:实现手机端与服务器之间进行通信,理解HttpURLConnection

二:设计思路和代码
1.创建一个加载网络图片的应用程序,将包名修改为cn.edu.bzu.imageviewdemo,设计交互式界面,创建主界面,对应的布局文件如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/iv"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" />

    <EditText
        android:id="@+id/et_path"
        android:layout_width="fill_parent"
        android:layout_height="wrap_conte
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值