Use Asynctask to display a ProgressBar in Android

后端 未结 5 1540
暖寄归人
暖寄归人 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:23

    Add to OnPostExecute method :

    pg.setVisibility(View.INVISIBLE);
    

    Add to onPreExecute method :

    pg.setVisibility(View.VISIBLE);
    

    and in Layout file you should add to progress bar :

    android:visibility="invisible" 
    

提交回复
热议问题