マニック、あなたが何をしたいのかあなたの質問を指定しますか?エディットテキストとボタンおよびWebサービスデータがあります。edittextを入力してボタンをクリックすると、ユーザー入力ごとにWebサービスデータが表示されなくなります。または他の何か。これを試してください
OK見てみましょう!
まず、プロジェクトのKSOAPライブラリをここからダウンロードする必要があります。Androidプラットフォーム用の軽量で効率的なSOAPクライアントライブラリです。このライブラリをプロジェクトに追加します。次のコードはあなたを助けます-
private Button button1;
private EditText editText1;
public void onClick(Bundle b){
........//type your other code here
editText1 = (EditText) findViewById(R.id.editText1);
button1 = (EditText) findViewById(R.id.button1);
button.setOnClickListener(this);
........//type your other code here
}
@Override
public void onClick(){
SoapObject soapResponseObject = getSOAPResponse(editText1.getText());
String result= soapResponseObject.getProperty(0).toString();
//use result to into your code to your own way
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();
}
//getSOAPResponse() method returns SOAP Response
public SoapObject getSOAPResponse(String search){
SoapObject soapObject = new SoapObject("http://www.webservicex.net", "GetBibleWordsbyKeyWord");
soapObject.addProperty("BibleWords", search);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE androidHttpTransport = new HttpTransportSE("http://www.webservicex.net/BibleWebservice.asmx?");
try {
androidHttpTransport.call("http://www.webserviceX.NET/GetBibleWordsbyKeyWord", envelope);//call the eb service Method
} catch (Exception e) {
e.printStackTrace();
}
return (SoapObject) envelope.response();
}
これがお役に立てば幸いです。楽しい!