Android Progressbar not updating

前端 未结 5 1315
情深已故
情深已故 2021-01-28 22:33

i got a problem in updating progress bar. I am updating progress bar in separate Thread and the variable on which the progressbar progress is depending(which is a class variable

5条回答
  •  情歌与酒
    2021-01-28 23:21

    You are updating progress bar inisde a thread's run method. you cannot update ui from a thread. You need to update ui on the ui thread. Use runOnUiThread. runOnUiThread is a method of activity class.

    Or Use Asynctask.

    http://developer.android.com/reference/android/os/AsyncTask.html

    In asynctask doInBackground you can call publishProgress(Progress...) to publish one or more units of progress. These values are published on the UI thread, in the onProgressUpdate(Progress...) step.

提交回复
热议问题