在活动标题栏显示加载图标图标、标题栏、加载

2023-09-04 12:52:27 作者:星辰误入眼底.

如何显示在活动标题栏的加载图标?

解决方案

  @覆盖
公共无效的onCreate(包冰柱){
    super.onCreate(冰柱);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    的setContentView(R.layout.your_layout);
}
 

则...在任何你想要的:

  //然后,你可以做到这一点,以显示图标
setProgressBarIndeterminateVisibility(真正的);
//或隐藏它
setProgressBarIndeterminateVisibility(假);
 

请务必使用 requestWindowFeature 的setContentView

Win8.1如何更改项目 标题栏 图标等 的大小

How do you show a loading icon in the activity titlebar?

解决方案

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.your_layout);
}

Then... where ever you want:

// then, you can do this to show the icon
setProgressBarIndeterminateVisibility(true);
//or to hide it
setProgressBarIndeterminateVisibility(false);

Make sure to use requestWindowFeature before setContentView.