我有一个简单的Android应用程序来访问Web服务。 我想显示一个对话框"Loading . . ." ...... "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(); } } }我该如何纠正这个问题?
I have a simple android application to access a web service. I want to show a dialog "Loading . . ." until results are loaded and dismissed after loading the results. I have used this code but this doesn't show the loading message:
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(); } } }How can I correct this problem ?
最满意答案
嗨尝试以下代码
private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { pd.show(); super.onPreExecute(); } @Override protected String doInBackground(String... urls) { String response = ""; 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(); } return response; } @Override protected void onPostExecute(String result) { pd.dismiss(); } }资源: http : //www.vogella.com/articles/AndroidPerformance/article.html
Hi try as following code
private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { pd.show(); super.onPreExecute(); } @Override protected String doInBackground(String... urls) { String response = ""; 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(); } return response; } @Override protected void onPostExecute(String result) { pd.dismiss(); } }Resource : http://www.vogella.com/articles/AndroidPerformance/article.html
如何添加“加载。(How to add a “Loading . . .” dialog to an android app)我有一个简单的Android应用程序来访问Web服务。 我想显示一个对话框"Loading . . ." ...... "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(); } } }我该如何纠正这个问题?
I have a simple android application to access a web service. I want to show a dialog "Loading . . ." until results are loaded and dismissed after loading the results. I have used this code but this doesn't show the loading message:
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(); } } }How can I correct this problem ?
最满意答案
嗨尝试以下代码
private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { pd.show(); super.onPreExecute(); } @Override protected String doInBackground(String... urls) { String response = ""; 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(); } return response; } @Override protected void onPostExecute(String result) { pd.dismiss(); } }资源: http : //www.vogella.com/articles/AndroidPerformance/article.html
Hi try as following code
private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { pd.show(); super.onPreExecute(); } @Override protected String doInBackground(String... urls) { String response = ""; 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(); } return response; } @Override protected void onPostExecute(String result) { pd.dismiss(); } }Resource : http://www.vogella.com/articles/AndroidPerformance/article.html
发布评论