1
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)

doesn't work for me, since it should be called before onCreate in the Activity, when I need to show it only when user pressed button in this Activity.

LA_
  • 19,823
  • 58
  • 172
  • 308

2 Answers2

3

You're on the right track. You do want to use:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

The trick is to toggle the display of the spinner via:

setProgressBarIndeterminateVisibility(boolean);

Pass true to show, false to hide. So in your Activity init or UI init then call it with false to hide it, then call it again with true to show it when your button click is fired.

pixel
  • 24,905
  • 36
  • 149
  • 251
Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68
0

I believe you can still set the progress bar's visibility via PROGRESS_VISIBILITY_OFF and PROGRESS_VISIBILITY_ON after you've called setContentView.

You can in fact set FEATURE_INDETERMINATE_PROGRESS in onCreate, it just needs to be before setContentView is called.

Matthew
  • 44,826
  • 10
  • 98
  • 87