Android中的Http通信(四)Post、Get传递参数

本文详细介绍了在Android应用中如何通过HTTP的GET和POST方式向服务器发送数据,包括处理服务器乱码问题。通过示例展示了如何在布局文件中设置输入框,并在Activity中编写对应的GET和POST请求,以及如何处理响应数据。
摘要由CSDN通过智能技术生成

本文主要介绍的是通过http中的GET方式和POST方式上传数据到服务器,其中涉及到解决服务器乱码问题。本文需要服务器和Android前端配合,由于这里是写android方面的问题,后台服务器我就写了一个简单的demo,废话不多说,直接开干。

遵循上一篇的习惯,先来一个布局吧:

[html]  view plain   copy
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <TextView  
  8.         android:layout_width="match_parent"  
  9.         android:layout_height="wrap_content"  
  10.         android:gravity="center_horizontal"  
  11.         android:text="用户名:童义\n密码:123456" />  
  12.   
  13.     <LinearLayout  
  14.         android:layout_width="match_parent"  
  15.         android:layout_height="wrap_content"  
  16.         android:layout_marginTop="10dp"  
  17.         android:orientation="horizontal" >  
  18.   
  19.         <TextView  
  20.             android:layout_width="0dp"  
  21.             android:layout_height="wrap_content"  
  22.             android:layout_weight="1"  
  23.             android:gravity="center_horizontal"  
  24.             android:text="用户名:" />  
  25.   
  26.         <EditText  
  27.             android:id="@+id/name"  
  28.             android:layout_width="0dp"  
  29.             android:layout_height="wrap_content"  
  30.             android:layout_weight="2"  
  31.             android:hint="用户名" />  
  32.     </LinearLayout>  
  33.   
  34.     <LinearLayout  
  35.         android:layout_width="match_parent"  
  36.         android:layout_height="wrap_content"  
  37.         android:layout_marginTop="10dp"  
  38.         android:orientation="horizontal" >  
  39.   
  40.         <TextView  
  41.             android:layout_width="0dp"  
  42.             android:layout_height="wrap_content"  
  43.             android:layout_weight
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值