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.
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.
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.
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.