如何显示不确定的进度栏时,pressed在ActionBarSherlock刷新按钮?不确定、进度、按钮、pressed

2023-09-06 00:15:32 作者:人生就像卫生纸尽量少扯

如何显示不确定进度刷新按钮pssed在$ P $ ActionBarSherlock 键,再次显示刷新按钮时的ViewGroup上刷新?

How to show Indeterminate ProgressBar when Refresh button is pressed in ActionBarSherlock and again show Refresh Button when ViewGroup on refreshed?

更新1: 我这里有一个答案是不完整的。我把对问题的赏金,让更多的开发者可以帮助建立一个很好的答案,可以对别人有用的未来。

Update 1: I have a answer here which is incomplete. I am placing a bounty on question so that more developers can help build a good answer which can useful to others in future.

我们如何能表现出不确定进度它看起来像图片中显示如下

How can we show a Indeterminate ProgressBar which looks like the one shown in the image below

推荐答案

这似乎是ActionBarSherlock不提供动画刷新菜单项具体方法。

It seems like ActionBarSherlock doesn't provide specific method to animate a refresh MenuItem.

你可以(通过使用经典的Andr​​oid API)什么是使用 setActionView(INT渣油)方法,并给出了一个布局ID与进度在里面。

What you can do (by using classic android API) is to use the setActionView(int resId) method and give the id of a layout with a ProgressBar in it.

在你的刷新操作的开始就叫:

At the beginning of your refresh action just call :

item.setActionView(R.layout.refresh_menuitem);

当你刷新动作完成的呼叫:

And when your refresh action is finished call :

item.setActionView(null);

下面是一个什么样的布局文件样本的 refresh_menuitem.xml 可以有:

Here is a sample of what your layout file refresh_menuitem.xml can have :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:addStatesFromChildren="true"
              android:focusable="true"
              android:paddingLeft="4dp"
              android:paddingRight="4dp"
              android:gravity="center"
              style="?attr/actionButtonStyle">
    <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="true"
            style="@android:style/Widget.ProgressBar.Small"/>
</LinearLayout>