一:进行主界面布局
<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"
android:background="@drawable/ba">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/input_city" />
<EditText
android:id="@+id/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search"/>
<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
二:导入KSOAP包
将ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar包拷贝到libs文件夹下,然后点击右键Build Path –> Configure Build Path...,会出现
然后将添加的包勾上...
三:调用天气预报的WebService1.指定 WebService 的命名空间和调用方法