显示进度微调(刷新)在动作条?进度、动作

2023-09-12 01:41:42 作者:假装陌生了

我使用的动作条。我想有一个刷新进度微调的标题栏,如果我将它设置为纺纱 - 否则隐藏它。这是可能的:

I'm using the ActionBar. I'd like to have a refresh progress spinner on the titlebar, if I set it to spinning - otherwise hide it. Is that possible?:

// My menu has a refresh item, but it shouldn't be visible on the
// actionbar unless it's spinning.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/menu_refresh"
    android:title="@string/refresh"
    android:icon="@drawable/ic_action_refresh" />
</menu>

...

// When I need to show some work being done on my activity,
// can I somehow now make the spinner associated with the
// refresh item become visible on the action bar?
getActionBarHelper().setRefreshActionItemState(true);

我不希望它在动作条,除非它是进行中/旋转着。

I don't want it on the ActionBar unless it's "in progress" / spinning.

感谢

推荐答案

道歉没有code标签,可以从手机发布...

Apologies for no code tags, posting from phone...

这是从ActionbarSherlock(谷歌,如果你还没有遇到过,可以让动作条在pre蜂窝载体)

This is from ActionbarSherlock (Google that if you've not come across it, allows actionbar support in pre honeycomb)

在主要活动的onCreate

In onCreate of main activity

// This has to be called before setContentView and you must use the 
// class in android.support.v4.view and NOT android.view

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

要显示操作栏/隐藏进度。与actionbarsherlock请注意,你必须使用boolean.TRUE / ​​FALSE,不只是真/假.........

To show/hide progress in action bar. Notice with actionbarsherlock you must use boolean.TRUE/FALSE, not just true/false.........

if (getSupportLoaderManager().hasRunningLoaders()) {
   setProgressBarIndeterminateVisibility(Boolean.TRUE); 
} else {
   setProgressBarIndeterminateVisibility(Boolean.FALSE); 
}