我有一个简单的 android 应用程序来访问 Web 服务。我想显示一个对话框"Loading . . ."
,直到加载结果并在加载结果后关闭。我已经使用了这段代码,但这没有显示加载消息:
public class LoadingActivity extends Activity {
private static final String SOAP_ACTION = "http://ws.eretailer.com/";
private static final String METHOD_NAME = "dataSender";
private static final String NAMESPACE = "http://ws.eretailer.com/dataSender/";
private static final String URL = "http://175.157.128.207:8085/Eretailer/services/EretailerService?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ProgressDialog pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setMessage("Loading. . .");
pd.show();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
pd.show();
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
pd.dismiss();
String str = s.toString();
String arr1[] = str.split(" ");
TextView tv = new TextView(this);
for(int i = 0; i<arr1.length;i++){
tv.append("order ID :"+arr1[i]+"\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
我怎样才能纠正这个问题?