Can I Update the string message of a ProgressDialog?

有些话、适合烂在心里 提交于 2019-12-10 15:14:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!