【发布时间】:2013-07-31 12:54:53
【问题描述】:
我在this 中使用了建议,但我还有同样的问题。 感谢我的朋友对使用 AsyncTask 的建议,但它对我不起作用。 什么? 这是我的代码:
DBAsyncTask dba = new DBAsyncTask(this, xmlCommand);
dba.inProcess = true;
dba.execute("");
while (dba.inProcess) {
try {
Thread.sleep(200);
println("wwwwait");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public class DBAsyncTask extends AsyncTask<String, Void, String> {
public boolean inProcess;
public DBAsyncTask(ExirCommandRunner commandRunner,XmlNode xmlCommand) {
this.commandRunner = commandRunner;
this.xmlCommand = xmlCommand;
}
@Override
protected void onPostExecute(String result) {
ExirDebugger.println("onPostExecute");
}
@Override
protected void onPreExecute() {
showProgress();
}
@Override
protected String doInBackground(String... params) {
///my process here
closeProgress();
return null;
}
谁能帮帮我?
【问题讨论】:
-
关闭进度应该在onPostExecute。
-
没有我的进程在关闭之前
-
@ArmaanStranger 为什么会这样。一旦 doInBackground 完成执行,就会自动调用 onPostExecute。
-
@ObieMD5 是的,它会被自动调用。所以关闭对话框应该在那个方法中。
-
@alishekari 你应该在 PostExecute 方法中关闭对话框。
标签: android android-asynctask progressdialog