上一个星期做的了,一直没有写,很悲伤啊,因为不太会。老师给了一个看了看,发现挺简单的还,并不难。
市面上的大多数的Android应用如新浪微博、网易新闻都是网络应用,都需要与服务器进行通信。下面通过这一个案例“网络图片浏览器”像大家演示手机端与服务器进行通信的过程。如下:
一、创建程序
创建一个“网络图片浏览器”应用程序,将包名改为cn.edu.bzu。设计用户交互页面。
"网络图片浏览器”对应的布局文件如下(activity_main.xml):
<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_content"
android:hint="请输入图片路径"
android:text="http://b.hiphotos.baidu.com/ima