我通过按钮调用asyncTask。它工作,它完成所有操作,但它没有显示我设置的ProgressDialog。
`私有类CaricaValori扩展了AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(MainActivity.this);
dialog.setTitle("Tratta");
dialog.setMessage("Carico tratta...");
dialog.setIndeterminate(false);
dialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
runOnUiThread(new Runnable() {
@Override
public void run()
{
// TODO: Implement this method
String start = startEdit.getText().toString();
String end = endEdit.getText().toString();
partenza = start.replace(" ", "+");
arrivo = end.replace(" ","+");
String Address = ReadAddressFromWebService(partenza,arrivo);
results.setText(Address);
//Toast.makeText(MainActivity.this,Address, Toast.LENGTH_LONG).show();
}
});
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
dialog.dismiss();
}
}`
看起来没错,但没有表现出来。