我正在使用ActionBar。我希望在标题栏上有一个刷新进度微调器,如果我将它设置为旋转 - 否则将其隐藏。这是可能的吗?:在ActionBar上显示进度微调(刷新)?
// 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);
我不希望它在ActionBar,除非它“正在进行”/旋转。
感谢
好谢谢我会在那里挖一下。随SDK提供的示例不如我最初的想法。他们使用Window.FEATURE_CUSTOM_TITLE,它可以在用户完全绘制之前向用户显示标题栏,这看起来确实不专业。叹。 – user291701 2012-01-30 14:02:32
@Jake Wharton我正在努力解决这个问题。当按下'refresh'按钮时,调用回调'onOptionsItemSelected'。在MartinS的建议下,我们在哪里调用setProgressBarIndeterminateVisibility? – 2012-06-05 20:59:50
如果您使用的是ActionBarSherlock,请确保使用setSupportProgressBarIndeterminateVisibility()。否则,你的进度指示器会一直旋转,你不知道为什么。 – 2012-11-11 21:14:39