利用WebService解析出的天气预报

 

利用WebService解析出的天气预报

事先声明,这个代码是《疯狂android讲义》上的,我只不过动手打了一遍,有些地方是拷贝的

布局文件

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <LinearLayout  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="wrap_content" >  
  10.   
  11.         <TextView  
  12.             android:layout_width="wrap_content"  
  13.             android:layout_height="wrap_content"  
  14.             android:hint="@string/province" />  
  15.         <!-- 让用户选择省份的Spinner -->  
  16.   
  17.         <Spinner  
  18.             android:id="@+id/province"  
  19.             android:layout_width="fill_parent"  
  20.             android:layout_height="wrap_content" />  
  21.     </LinearLayout>  
  22.   
  23.     <LinearLayout  
  24.         android:layout_width="fill_parent"  
  25.         android:layout_height="wrap_content" >  
  26.   
  27.         <TextView  
  28.             android:layout_width="wrap_content"  
  29.             android:layout_height="wrap_content"  
  30.             android:hint="@string/city" />  
  31.         <!-- 让用户选择城市的Spinner -->  
  32.   
  33.         <Spinner  
  34.             android:id="@+id/city"  
  35.             android:layout_width="fill_parent"  
  36.             android:layout_height="wrap_content" />  
  37.     </LinearLayout>  
  38.     <!-- 显示今天天气的图片和文本框 -->  
  39.   
  40.     <LinearLayout  
  41.         android:layout_width="fill_parent"  
  42.         android:layout_height="wrap_content" >  
  43.   
  44.         <ImageView  
  45.             android:id="@+id/todayWhIcon1"  
  46.             android:layout_width="wrap_content"  
  47.             android:layout_height="wrap_content" />  
  48.   
  49.         <ImageView  
  50.             android:id="@+id/todayWhIcon2"  
  51.             android:layout_width="wrap_content"  
  52.             android:layout_height="wrap_content" />  
  53.   
  54.         <TextView  
  55.             android:id="@+id/weatherToday"  
  56.             android:layout_width="fill_parent"  
  57.             android:layout_height="wrap_content"  
  58.             android:layout_weight="1" />  
  59.     </LinearLayout>  
  60.     <!-- 显示明天天气的图片和文本框 -->  
  61.   
  62.     <LinearLayout  
  63.         android:layout_width="fill_parent"  
  64.         android:layout_height="wrap_content" >  
  65.   
  66.         <ImageView  
  67.             android:id="@+id/tomorrowWhIcon1"  
  68.             android:layout_width="wrap_content"  
  69.             android:layout_height="wrap_content" />  
  70.   
  71.         <ImageView  
  72.             android:id="@+id/tomorrowWhIcon2"  
  73.             android:layout_width="wrap_content"  
  74.             android:layout_height="wrap_content" />  
  75.   
  76.         <TextView  
  77.             android:id="@+id/weatherTomorrow"  
  78.             android:layout_width="fill_parent"  
  79.             android:layout_height="wrap_content"  
  80.             android:layout_weight="1" />  
  81.     </LinearLayout>  
  82.     <!-- 显示后天天气的图片和文本框 -->  
  83.   
  84.     <LinearLayout  
  85.         android:layout_width="fill_parent"  
  86.         android:layout_height="wrap_content" >  
  87.   
  88.         <ImageView  
  89.             android:id="@+id/afterdayWhIcon1"  
  90.             android:layout_width="wrap_content"  
  91.             android:layout_height="wrap_content" />  
  92.   
  93.         <ImageView  
  94.             android:id="@+id/afterdayWhIcon2"  
  95.             android:layout_width="wrap_content"  
  96.             android:layout_height="wrap_content" />  
  97.   
  98.         <TextView  
  99.             android:id="@+id/weatherAfterday"  
  100.             android:layout_width="fill_parent"  
  101.             android:layout_height="wrap_content"  
  102.             android:layout_weight="1" />  
  103.     </LinearLayout>  
  104.   
  105.     <TextView  
  106.         android:id="@+id/weatherCurrent"  
  107.         android:layout_width="fill_parent"  
  108.         android:layout_height="wrap_content" />  
  109.   
  110. </LinearLayout>  

主要activity文件



[java]  view plain copy print ?
  1. package com.example.weatherservicedemo;  
  2.   
  3. import java.util.List;  
  4. import org.ksoap2.serialization.SoapObject;  
  5. import android.app.Activity;  
  6. import android.os.Bundle;  
  7. import android.view.View;  
  8. import android.widget.AdapterView;  
  9. import android.widget.AdapterView.OnItemSelectedListener;  
  10. import android.widget.ImageView;  
  11. import android.widget.Spinner;  
  12. import android.widget.TextView;  
  13.   
  14. /** 
  15.  * Description: <br/> 
  16.  * site: <a href="http://www.crazyit.org">crazyit.org</a> <br/> 
  17.  * Copyright (C), 2001-2012, Yeeku.H.Lee <br/> 
  18.  * This program is protected by copyright laws. <br/> 
  19.  * Program Name: <br/> 
  20.  * Date: 
  21.  *  
  22.  * @author Yeeku.H.Lee kongyeeku@163.com 
  23.  * @version 1.0 
  24.  */  
  25. public class MyWeather extends Activity {  
  26.     private Spinner provinceSpinner;  
  27.     private Spinner citySpinner;  
  28.     private ImageView todayWhIcon1;  
  29.     private ImageView todayWhIcon2;  
  30.     private TextView textWeatherToday;  
  31.     private ImageView tomorrowWhIcon1;  
  32.     private ImageView tomorrowWhIcon2;  
  33.     private TextView textWeatherTomorrow;  
  34.     private ImageView afterdayWhIcon1;  
  35.     private ImageView afterdayWhIcon2;  
  36.     private TextView textWeatherAfterday;  
  37.     private TextView textWeatherCurrent;  
  38.   
  39.     @Override  
  40.     public void onCreate(Bundle savedInstanceState) {  
  41.         super.onCreate(savedInstanceState);  
  42.         setContentView(R.layout.activity_main);  
  43.   
  44.         todayWhIcon1 = (ImageView) findViewById(R.id.todayWhIcon1);  
  45.         todayWhIcon2 = (ImageView) findViewById(R.id.todayWhIcon2);  
  46.         textWeatherToday = (TextView) findViewById(R.id.weatherToday);  
  47.         tomorrowWhIcon1 = (ImageView) findViewById(R.id.tomorrowWhIcon1);  
  48.         tomorrowWhIcon2 = (ImageView) findViewById(R.id.tomorrowWhIcon2);  
  49.         textWeatherTomorrow = (TextView) findViewById(R.id.weatherTomorrow);  
  50.         afterdayWhIcon1 = (ImageView) findViewById(R.id.afterdayWhIcon1);  
  51.         afterdayWhIcon2 = (ImageView) findViewById(R.id.afterdayWhIcon2);  
  52.         textWeatherAfterday = (TextView) findViewById(R.id.weatherAfterday);  
  53.         textWeatherCurrent = (TextView) findViewById(R.id.weatherCurrent);  
  54.   
  55.         // 获取程序界面中选择省份、城市的Spinner组件  
  56.         provinceSpinner = (Spinner) findViewById(R.id.province);  
  57.         citySpinner = (Spinner) findViewById(R.id.city);  
  58.         // 调用远程Web Service获取省份列表  
  59.         List<String> provinces = WebServiceUtil.getProvinceList();  
  60.         ListAdapter adapter = new ListAdapter(this, provinces);  
  61.         // 使用Spinner显示省份列表  
  62.         provinceSpinner.setAdapter(adapter);  
  63.         // 当省份Spinner的选择项被改变时  
  64.         provinceSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {  
  65.             public void onItemSelected(AdapterView<?> source, View parent,  
  66.                     int position, long id) {  
  67.                 List<String> cities = WebServiceUtil  
  68.                         .getCityListByProvince(provinceSpinner  
  69.                                 .getSelectedItem().toString());  
  70.                 ListAdapter cityAdapter = new ListAdapter(MyWeather.this,  
  71.                         cities);  
  72.                 // 使用Spinner显示城市列表  
  73.                 citySpinner.setAdapter(cityAdapter);  
  74.             }  
  75.   
  76.             public void onNothingSelected(AdapterView<?> arg0) {  
  77.             }  
  78.         });  
  79.         // 当城市Spinner的选择项被改变时  
  80.         citySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {  
  81.             public void onItemSelected(AdapterView<?> source, View parent,  
  82.                     int position, long id) {  
  83.                 showWeather(citySpinner.getSelectedItem().toString());  
  84.             }  
  85.   
  86.             public void onNothingSelected(AdapterView<?> arg0) {  
  87.             }  
  88.         });  
  89.     }  
  90.   
  91.     private void showWeather(String city) {  
  92.         String weatherToday = null;  
  93.         String weatherTomorrow = null;  
  94.         String weatherAfterday = null;  
  95.         String weatherCurrent = null;  
  96.         int iconToday[] = new int[2];  
  97.         int iconTomorrow[] = new int[2];  
  98.         int iconAfterday[] = new int[2];  
  99.         // 获取远程Web Service返回的对象  
  100.         SoapObject detail = WebServiceUtil.getWeatherByCity(city);  
  101.         // 获取天气实况  
  102.         weatherCurrent = detail.getProperty(4).toString();  
  103.         // 解析今天的天气情况  
  104.         String date = detail.getProperty(7).toString();  
  105.         weatherToday = "今天:" + date.split(" ")[0];  
  106.         weatherToday = weatherToday + "\n天气:" + date.split(" ")[1];  
  107.         weatherToday = weatherToday + "\n气温:"  
  108.                 + detail.getProperty(8).toString();  
  109.         weatherToday = weatherToday + "\n风力:"  
  110.                 + detail.getProperty(9).toString() + "\n";  
  111.         iconToday[0] = parseIcon(detail.getProperty(10).toString());  
  112.         iconToday[1] = parseIcon(detail.getProperty(11).toString());  
  113.         // 解析明天的天气情况  
  114.         date = detail.getProperty(12).toString();  
  115.         weatherTomorrow = "明天:" + date.split(" ")[0];  
  116.         weatherTomorrow = weatherTomorrow + "\n天气:" + date.split(" ")[1];  
  117.         weatherTomorrow = weatherTomorrow + "\n气温:"  
  118.                 + detail.getProperty(13).toString();  
  119.         weatherTomorrow = weatherTomorrow + "\n风力:"  
  120.                 + detail.getProperty(14).toString() + "\n";  
  121.         iconTomorrow[0] = parseIcon(detail.getProperty(15).toString());  
  122.         iconTomorrow[1] = parseIcon(detail.getProperty(16).toString());  
  123.         // 解析后天的天气情况  
  124.         date = detail.getProperty(17).toString();  
  125.         weatherAfterday = "后天:" + date.split(" ")[0];  
  126.         weatherAfterday = weatherAfterday + "\n天气:" + date.split(" ")[1];  
  127.         weatherAfterday = weatherAfterday + "\n气温:"  
  128.                 + detail.getProperty(18).toString();  
  129.         weatherAfterday = weatherAfterday + "\n风力:"  
  130.                 + detail.getProperty(19).toString() + "\n";  
  131.         iconAfterday[0] = parseIcon(detail.getProperty(20).toString());  
  132.         iconAfterday[1] = parseIcon(detail.getProperty(21).toString());  
  133.         // 更新当天的天气实况  
  134.         textWeatherCurrent.setText(weatherCurrent);  
  135.         // 更新显示今天天气的图标和文本框  
  136.         textWeatherToday.setText(weatherToday);  
  137.         todayWhIcon1.setImageResource(iconToday[0]);  
  138.         todayWhIcon2.setImageResource(iconToday[1]);  
  139.         // 更新显示明天天气的图标和文本框  
  140.         textWeatherTomorrow.setText(weatherTomorrow);  
  141.         tomorrowWhIcon1.setImageResource(iconTomorrow[0]);  
  142.         tomorrowWhIcon2.setImageResource(iconTomorrow[1]);  
  143.         // 更新显示后天天气的图标和文本框  
  144.         textWeatherAfterday.setText(weatherAfterday);  
  145.         afterdayWhIcon1.setImageResource(iconAfterday[0]);  
  146.         afterdayWhIcon2.setImageResource(iconAfterday[1]);  
  147.     }  
  148.   
  149.     // 工具方法,该方法负责把返回的天气图标字符串,转换为程序的图片资源ID。  
  150.     private int parseIcon(String strIcon) {  
  151.         if (strIcon == null)  
  152.             return -1;  
  153.         if ("0.gif".equals(strIcon))  
  154.             return R.drawable.a_0;  
  155.         if ("1.gif".equals(strIcon))  
  156.             return R.drawable.a_1;  
  157.         if ("2.gif".equals(strIcon))  
  158.             return R.drawable.a_2;  
  159.         if ("3.gif".equals(strIcon))  
  160.             return R.drawable.a_3;  
  161.         if ("4.gif".equals(strIcon))  
  162.             return R.drawable.a_4;  
  163.         if ("5.gif".equals(strIcon))  
  164.             return R.drawable.a_5;  
  165.         if ("6.gif".equals(strIcon))  
  166.             return R.drawable.a_6;  
  167.         if ("7.gif".equals(strIcon))  
  168.             return R.drawable.a_7;  
  169.         if ("8.gif".equals(strIcon))  
  170.             return R.drawable.a_8;  
  171.         if ("9.gif".equals(strIcon))  
  172.             return R.drawable.a_9;  
  173.         if ("10.gif".equals(strIcon))  
  174.             return R.drawable.a_10;  
  175.         if ("11.gif".equals(strIcon))  
  176.             return R.drawable.a_11;  
  177.         if ("12.gif".equals(strIcon))  
  178.             return R.drawable.a_12;  
  179.         if ("13.gif".equals(strIcon))  
  180.             return R.drawable.a_13;  
  181.         if ("14.gif".equals(strIcon))  
  182.             return R.drawable.a_14;  
  183.         if ("15.gif".equals(strIcon))  
  184.             return R.drawable.a_15;  
  185.         if ("16.gif".equals(strIcon))  
  186.             return R.drawable.a_16;  
  187.         if ("17.gif".equals(strIcon))  
  188.             return R.drawable.a_17;  
  189.         if ("18.gif".equals(strIcon))  
  190.             return R.drawable.a_18;  
  191.         if ("19.gif".equals(strIcon))  
  192.             return R.drawable.a_19;  
  193.         if ("20.gif".equals(strIcon))  
  194.             return R.drawable.a_20;  
  195.         if ("21.gif".equals(strIcon))  
  196.             return R.drawable.a_21;  
  197.         if ("22.gif".equals(strIcon))  
  198.             return R.drawable.a_22;  
  199.         if ("23.gif".equals(strIcon))  
  200.             return R.drawable.a_23;  
  201.         if ("24.gif".equals(strIcon))  
  202.             return R.drawable.a_24;  
  203.         if ("25.gif".equals(strIcon))  
  204.             return R.drawable.a_25;  
  205.         if ("26.gif".equals(strIcon))  
  206.             return R.drawable.a_26;  
  207.         if ("27.gif".equals(strIcon))  
  208.             return R.drawable.a_27;  
  209.         if ("28.gif".equals(strIcon))  
  210.             return R.drawable.a_28;  
  211.         if ("29.gif".equals(strIcon))  
  212.             return R.drawable.a_29;  
  213.         if ("30.gif".equals(strIcon))  
  214.             return R.drawable.a_30;  
  215.         if ("31.gif".equals(strIcon))  
  216.             return R.drawable.a_31;  
  217.         return 0;  
  218.     }  
  219. }  

帮助文件



[java]  view plain copy print ?
  1. package com.example.weatherservicedemo;  
  2.   
  3. import java.io.IOException;  
  4. import java.util.ArrayList;  
  5. import java.util.List;  
  6.   
  7. import org.ksoap2.SoapEnvelope;  
  8. import org.ksoap2.serialization.SoapObject;  
  9. import org.ksoap2.serialization.SoapSerializationEnvelope;  
  10. import org.ksoap2.transport.HttpTransportSE;  
  11. import org.xmlpull.v1.XmlPullParserException;  
  12.   
  13. /** 
  14.  * Description: <br/> 
  15.  * 网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> <br/> 
  16.  * Copyright (C), 2001-2012, Yeeku.H.Lee <br/> 
  17.  * This program is protected by copyright laws. <br/> 
  18.  * Program Name: <br/> 
  19.  * Date: 
  20.  *  
  21.  * @author Yeeku.H.Lee kongyeeku@163.com 
  22.  * @version 1.0 
  23.  */  
  24. public class WebServiceUtil {  
  25.     // 定义Web Service的命名空间  
  26.     static final String SERVICE_NS = "http://WebXml.com.cn/";  
  27.     // 定义Web Service提供服务的URL  
  28.     static final String SERVICE_URL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";  
  29.   
  30.     // 调用远程Web Service获取省份列表  
  31.     public static List<String> getProvinceList() {  
  32.         // 调用的方法  
  33.         String methodName = "getRegionProvince";  
  34.         // 创建HttpTransportSE传输对象  
  35.         HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);  
  36.         ht.debug = true;  
  37.         // 使用SOAP1.1协议创建Envelop对象  
  38.         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(  
  39.                 SoapEnvelope.VER11);  
  40.         // 实例化SoapObject对象  
  41.         SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);  
  42.         envelope.bodyOut = soapObject;  
  43.         // 设置与.Net提供的Web Service保持较好的兼容性  
  44.         envelope.dotNet = true;  
  45.         try {  
  46.             // 调用Web Service  
  47.             ht.call(SERVICE_NS + methodName, envelope);  
  48.             if (envelope.getResponse() != null) {  
  49.                 // 获取服务器响应返回的SOAP消息  
  50.                 SoapObject result = (SoapObject) envelope.bodyIn;  
  51.                 SoapObject detail = (SoapObject) result.getProperty(methodName  
  52.                         + "Result");  
  53.                 // 解析服务器响应的SOAP消息。  
  54.                 return parseProvinceOrCity(detail);  
  55.             }  
  56.         } catch (IOException e) {  
  57.             e.printStackTrace();  
  58.         } catch (XmlPullParserException e) {  
  59.             e.printStackTrace();  
  60.         }  
  61.         return null;  
  62.     }  
  63.   
  64.     // 根据省份获取城市列表  
  65.     public static List<String> getCityListByProvince(String province) {  
  66.         // 调用的方法  
  67.         String methodName = "getSupportCityString";  
  68.         // 创建HttpTransportSE传输对象  
  69.         HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);  
  70.         ht.debug = true;  
  71.         // 实例化SoapObject对象  
  72.         SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);  
  73.         // 添加一个请求参数  
  74.         soapObject.addProperty("theRegionCode", province);  
  75.         // 使用SOAP1.1协议创建Envelop对象  
  76.         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(  
  77.                 SoapEnvelope.VER11);  
  78.         envelope.bodyOut = soapObject;  
  79.         // 设置与.Net提供的Web Service保持较好的兼容性  
  80.         envelope.dotNet = true;  
  81.         try {  
  82.             // 调用Web Service  
  83.             ht.call(SERVICE_NS + methodName, envelope);  
  84.             if (envelope.getResponse() != null) {  
  85.                 // 获取服务器响应返回的SOAP消息  
  86.                 SoapObject result = (SoapObject) envelope.bodyIn;  
  87.                 SoapObject detail = (SoapObject) result.getProperty(methodName  
  88.                         + "Result");  
  89.                 // 解析服务器响应的SOAP消息。  
  90.                 return parseProvinceOrCity(detail);  
  91.             }  
  92.         } catch (IOException e) {  
  93.             e.printStackTrace();  
  94.         } catch (XmlPullParserException e) {  
  95.             e.printStackTrace();  
  96.         }  
  97.         return null;  
  98.     }  
  99.   
  100.     private static List<String> parseProvinceOrCity(SoapObject detail) {  
  101.         ArrayList<String> result = new ArrayList<String>();  
  102.         for (int i = 0; i < detail.getPropertyCount(); i++) {  
  103.             // 解析出每个省份  
  104.             result.add(detail.getProperty(i).toString().split(",")[0]);  
  105.         }  
  106.         return result;  
  107.     }  
  108.   
  109.     public static SoapObject getWeatherByCity(String cityName) {  
  110.         String methodName = "getWeather";  
  111.         HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);  
  112.         ht.debug = true;  
  113.         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(  
  114.                 SoapEnvelope.VER11);  
  115.         SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);  
  116.         soapObject.addProperty("theCityCode", cityName);  
  117.         envelope.bodyOut = soapObject;  
  118.         // 设置与.Net提供的Web Service保持较好的兼容性  
  119.         envelope.dotNet = true;  
  120.         try {  
  121.             ht.call(SERVICE_NS + methodName, envelope);  
  122.             SoapObject result = (SoapObject) envelope.bodyIn;  
  123.             SoapObject detail = (SoapObject) result.getProperty(methodName  
  124.                     + "Result");  
  125.             return detail;  
  126.         } catch (Exception e) {  
  127.             e.printStackTrace();  
  128.         }  
  129.         return null;  
  130.     }  
  131. }  

适配器文件



[java]  view plain copy print ?
  1. package com.example.weatherservicedemo;  
  2.   
  3. import java.util.List;  
  4. import android.content.Context;  
  5. import android.graphics.Color;  
  6. import android.view.View;  
  7. import android.view.ViewGroup;  
  8. import android.widget.BaseAdapter;  
  9. import android.widget.TextView;  
  10.   
  11. /** 
  12.  * Description: <br/> 
  13.  * 网站: <a href="http://www.crazyit.org">疯狂Java联盟</a> <br/> 
  14.  * Copyright (C), 2001-2012, Yeeku.H.Lee <br/> 
  15.  * This program is protected by copyright laws. <br/> 
  16.  * Program Name: <br/> 
  17.  * Date: 
  18.  *  
  19.  * @author Yeeku.H.Lee kongyeeku@163.com 
  20.  * @version 1.0 
  21.  */  
  22. public class ListAdapter extends BaseAdapter {  
  23.     private Context context;  
  24.     private List<String> values;  
  25.   
  26.     public ListAdapter(Context context, List<String> values) {  
  27.         this.context = context;  
  28.         this.values = values;  
  29.     }  
  30.   
  31.     public int getCount() {  
  32.         return values.size();  
  33.     }  
  34.   
  35.     public Object getItem(int position) {  
  36.         return values.get(position);  
  37.     }  
  38.   
  39.     public long getItemId(int position) {  
  40.         return position;  
  41.     }  
  42.   
  43.     public View getView(int position, View convertView, ViewGroup parent) {  
  44.         TextView text = new TextView(context);  
  45.         text.setText(values.get(position));  
  46.         text.setTextSize(20);  
  47.         text.setTextColor(Color.BLACK);  
  48.         return text;  
  49.     }  
  50. }  

还有访问网络的权限呀,事先说明一下,这个只有在wif下运行成功,移动网络运行失败,不知道怎么回事,有明白的,给哥们呢我留个言,大恩不言谢呀。



[html]  view plain copy print ?
  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     package="com.example.weatherservicedemo"  
  3.     android:versionCode="1"  
  4.     android:versionName="1.0" >  
  5.   
  6.     <uses-sdk android:minSdkVersion="8" />  
  7.   
  8.     <uses-permission android:name="android.permission.INTERNET" />  
  9.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />  
  10.     <uses-permission android:name="android.permission.READ_PHONE_STATE" />  
  11.   
  12.     <application  
  13.         android:icon="@drawable/ic_launcher"  
  14.         android:label="@string/app_name"  
  15.         android:theme="@style/AppTheme" >  
  16.         <activity  
  17.             android:name=".MyWeather"  
  18.             android:label="@string/title_activity_main" >  
  19.             <intent-filter>  
  20.                 <action android:name="android.intent.action.MAIN" />  
  21.   
  22.                 <category android:name="android.intent.category.LAUNCHER" />  
  23.             </intent-filter>  
  24.         </activity>  
  25.     </application>  
  26.   
  27. </manifest>  

后面我会把源代码上传,因为还有一个架包没办法贴出来。也可以百度搜索一下,ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar架包


运行的时候可能会有no class not found 的错误,说找不到那个类文件,告诉你一个解决的办法,如下图

也可以看这篇文章解决---http://blog.csdn.net/wang6279026/article/details/8098100


转载于:https://my.oschina.net/luqin/blog/84477

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值