下面写的方法用来显示progressDialog(Just a spinner),
我已将 setCancelable 和 setIndeterminate 设置为 false,因为我不希望用户关闭此 progressDailog。我的问题是,我不知道如何在完成 AsyncTask 后关闭此 progressDialog。请帮助我,我在谷歌上搜索了几个小时来解决同样的问题,看到很多类似的问题,但这些都没有解决我的问题!
public class ListFriends extends ListActivity {
int intStat;
private static final int HOME = 0;
private static final int ADD = 1;
private static final int LOGOUT = 2;
private static final int SETTINGS = 3;
//private String friend;
private String user;
private String deviceUser;
private String friendNameGlobal;
....
....
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
........
........
loadFromServer(user);
}
private void loadFromServer(String userReceived) {
//buildToast("Please Wait while Updating The List");
showProgress();
String URL = "http://"+server+"/friendlistmob.php?userid="+userReceived;
new DownloadXmlTask().execute(URL);
}
private class DownloadXmlTask extends AsyncTask<String, Void, String> {
.....
.....
}
protected void onPostExecute(String result) {
progressDialog.dismiss();//not working
}
....
....
public void showProgress()
{
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(false);
progressDialog.setMessage("Please Wait while updating List");
progressDialog.show();
}
}