问题
I set up a progressdialog in an Android AsyncTak and it works.
My question is it possible to update in the onProgressUpdate method of the AsyncTask the string that the ProgressDialog displays. I would like to update the string with a publishProgress call to show progress of the task.
I can update the string if instead of the progressDialog I have my own textview. The progressDialog looks better and has the spinning wheel.
回答1:
Yes you can. Simply call myProgressDialog.setMessage("My New Message"); in onProgressUpdate method
回答2:
If you'll change message more then once:
@Override
protected void onProgressUpdate(final String... values) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progress.setMessage(values[0]);
}
});
}
来源:https://stackoverflow.com/questions/5009288/can-i-update-the-string-message-of-a-progressdialog