編輯:關於android開發
代碼示例:
package com.study.ws;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class WSClient extends Activity {
private Button search;
private EditText phone;
private TextView result;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
search=(Button)findViewById(R.id.search);
phone=(EditText)findViewById(R.id.phone);
result=(TextView)findViewById(R.id.result);
search.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String strPhone=phone.getText().toString().trim();
if(!(strPhone.length()==0||strPhone.equals("")))
{
String str = "";
try {
str = getPhoneInfo(strPhone);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.setText(str);
}
}
});
}
public String getPhoneInfo(String phoneName) throws IOException, XmlPullParserException
{
//返回的查詢結果
String result = null;
//調用webservice接口的名稱空間
String nameSpace="";
//調用的方法名
String methodName="getMobileCodeInfo";
//將方法名和名稱空間綁定在一起
String SOAP_ACTION = nameSpace + methodName;
//獲得返回請求對象
SoapObject request = new SoapObject(nameSpace, methodName);
//設置需要返回請求對象的參數
request.addProperty("mobileCode", phoneName);
request.addProperty("userId", "");
//設置soap的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
//設置是否調用的是dotNet開發的
envelope.dotNet = true;
//
envelope.bodyOut = request;
AndroidHttpTransport hts = new AndroidHttpTransport
("http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx");
// web service請求
hts.call(SOAP_ACTION, envelope);
// 得到返回結果
Object o = envelope.getResponse();
result = o.toString();
return result;
}
}
android不同的按鈕一起點擊崩潰解決,android一起public class ButtonUtils { private static long last
android 官方DrawerLayout的介紹和使用,androiddrawerlayout南塵:愛編程,愛安卓,每天進步一點點。 drawerLayout是Supp
零停重啟程序工具Huptime研究零停重啟程序工具Huptime研究.pdf目錄目錄11.官網12.功能13.環境要求24.實現原理25.SIGHUP信號處理 36.重啟
我的Android進階之旅------)android Button上面的英文字符串自動大寫的問題解決 今天碰到一個關於Button的問題:android Butto