你好,游客 登录 注册 搜索
背景:
阅读新闻

Android调用webservice实现手机归属查询

[日期:2012-10-17] 来源:Linux社区  作者:johnjobs [字体:大 中 小]

Android中的webservice调用方式与java中差异较大,经过查找些资料和例子,自己这边儿就做了个总结,写了个例子,谈不上原创(惭愧ing...),不过这方面的例子确实都大体相似,因为大家能写成博文的,发布成例子的,调用的接口大抵是网上公开的接口,如天气啊,手机号码段啊之类的,公司内部的接口,肯定是不能外透的,但是调用的方式确实一样,所以记录下来,方便大家研究,或者自己今后用到。

老习惯,先上效果图:

  图一

  图二

再上项目结构图:

第一步,加入调用webservice的jar包,ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar,下面会提供附件下载。

第二步,编辑activity_main.xml布局出效果图一所示效果,代码如下:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
  3.     android:orientation="vertical"   
  4.     android:layout_width="fill_parent"   
  5.     android:layout_height="fill_parent"   
  6.     android:paddingTop="5dip"   
  7.     android:paddingLeft="5dip"   
  8.     android:paddingRight="5dip"   
  9.     >   
  10.     <TextView   
  11.         android:layout_width="fill_parent"     
  12.         android:layout_height="wrap_content"     
  13.         android:text="手机号码(段):"   
  14.     />   
  15.     <EditText android:id="@+id/phone_sec"   
  16.         android:layout_width="fill_parent"   
  17.         android:layout_height="wrap_content"   
  18.         android:inputType="textPhonetic"   
  19.         android:singleLine="true"   
  20.         android:hint="例如:1398547"   
  21.     />   
  22.     <Button android:id="@+id/query_btn"   
  23.         android:layout_width="wrap_content"   
  24.         android:layout_height="wrap_content"   
  25.         android:layout_gravity="right"   
  26.         android:text="查询"   
  27.     />   
  28.     <TextView android:id="@+id/result_text"   
  29.         android:layout_width="wrap_content"     
  30.         android:layout_height="wrap_content"     
  31.         android:layout_gravity="center_horizontal|center_vertical"   
  32.     />   
  33. </LinearLayout>   
linux
相关资讯       Android开发基础教程  WebService 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款