Use Asynctask to display a ProgressBar in Android

后端 未结 5 1544
暖寄归人
暖寄归人 2021-01-24 15:59

I am trying to do display a ProgressBar.

I am an Android beginner.

When I press the button, the task should be running in the background, but it does not display

5条回答
  •  攒了一身酷
    2021-01-24 16:22

    Use ProgressDialog. You don't need any layout in this case.

    ProgressDialog progressDialog = new ProgressDialog(context);
    

    in onPreExecute show it

    progressDialog.show();
    

    and in onPostExecute dissmiss it

    progressDialog.dismiss();
    

提交回复
热议问题