SetProgressBarIndeterminateVisibility缺乏理解

Sir*_*owy 6 android

如果我在我的主Activity中请求这样的进度对话框,那么它将按预期显示:

          requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);  
  setProgressBarIndeterminateVisibility(true); 
Run Code Online (Sandbox Code Playgroud)

但是,如果我将可见性设置为"false",然后在我想要部署它的被调用过程中将其重置为"true",则不会显示任何内容.将requestWindowFeature移动到该过程会导致异常.我该怎么做?

Nik*_*kov 9

在打电话之前requestWindowFeature(),您只需拨打一次onCreate()电话setContentView().然后,您可以使用setProgressBarIndeterminateVisibility(true|false)从活动中的任何位置显示或隐藏进度指示器(当然,只要它在UI线程上).