请问有谁做过吗?我在网上找了好多例子,但是转到自己的电脑上总是有问题,实在搞不懂为什么,请教大家。。。
package webservice.weather;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
public class WeatherActivity extends Activity {
private static String LOG_TAG = "Weather";
private static boolean DEBUG = false;
private static final int SHOW_ABOUT = 0x0001;
private static final String NAMESPACE = "http://WebXml.com.cn/";
private static String URL = "http://www.webxml.com.cn/webservices/weatherwebservice.asmx";
private static final String METHOD_NAME = "getWeatherbyCityName";
private static String SOAP_ACTION = "http://WebXml.com.cn/getWeatherbyCityName";
private String weatherToday;
private String weatherTomorrow;
private String weatherAfterday;
private String weatherCurrent;
private int iconToday[] = new int[2];
private int iconTomorrow[] = new int[2];
private int iconAfterday[] = new int[2];
private Button okButton;
private EditText textInput;
private ImageView imageView1;
private ImageView imageView2;
private TextView textWeatherToday;
private ImageView imageView3;
private ImageView imageView4;
private TextView textWeatherTomorrow;
private ImageView imageView5;
private ImageView imageView6;
private TextView textWeatherAfterday;
private TextView textWeatherCurrent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
okButton = (Button) findViewById(R.id.WeatherSearch);
textInput = (EditText) findViewById(R.id.TextWeather);
imageView1 = (ImageView) findViewById(R.id.ImageView01);
imageView2 = (ImageView) findViewById(R.id.ImageView02);
textWeatherToday = (TextView) findViewById(R.id.WeatherToday);
imageView3 = (ImageView) findViewById(R.id.ImageView03);
imageView4 = (ImageView) findViewById(R.id.ImageView04);
textWeatherTomorrow = (TextView) findViewById(R.id.WeatherTomorrow);
imageView5 = (ImageView) findViewById(R.id.ImageView05);
imageView6 = (ImageView) findViewById(R.id.ImageView06);
textWeatherAfterday = (TextView) findViewById(R.id.WeatherAfterday);
textWeatherCurrent = (TextView) findViewById(R.id.WeatherCurrent);
okButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
showWeather();
}
});
}
private void showWeather() {
String city = textInput.getText().toString();
if (city.length() == 0)
city = "杭州";
getWeather(city);
textWeatherToday.setText(getWeatherToday());
imageView1.setImageResource(getIconToday(0));
imageView2.setImageResource(getIconToday(1));
textWeatherTomorrow.setText(getWeatherTomorrow());
imageView3.setImageResource(getIconTomorrow(0));
imageView4.setImageResource(getIconTomorrow(1));
textWeatherAfterday.setText(getWeatherAfterday());
imageView5.setImageResource(getIconAfterday(0));
imageView6.setImageResource(getIconAfterday(1));
textWeatherCurrent.setText(getWeatherCurrent());