i am trying to show a refresh animation in my action bar sherlock. the animation works just fine (rotating the refresh icon) and does what it is supposed to. The only problem is the text/label for the button disappears although there is enough space available. It returns as soon as the animation stops.
here are my code snippets:
anim/rotate.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="360"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1500"
android:interpolator="@android:anim/linear_interpolator" />
menu items xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_refresh"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="0"
android:showAsAction="withText|ifRoom"
android:title="@string/menu_refresh"/>
</menu>
layout/refresh_action.xml
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_refresh"
android:showAsAction="withText|ifRoom"
android:title="@string/menu_refresh"
style="@style/Widget.Sherlock.ActionButton" />
and the java code in my fragment
private Animation rotation;
private static ImageView syncView;
private static MenuItem syncItem;
private void refreshAnimation() {
/* Attach a rotating ImageView to the refresh item as an ActionView */
LayoutInflater lI = (LayoutInflater) getActivity()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
refreshView = (ImageView) lI.inflate(R.layout
.refresh_rotate_action, null);
rotation = AnimationUtils.loadAnimation(getActivity(),
R.anim.refresh_rotate);
rotation.setAnimationListener(rotateListener);
refreshView.startAnimation(rotation);
refreshItem.setActionView(syncView);
}
I hope someone here has a solution for this problem because it is driving me crazy.
There is a rotating loading view built into the actionbar. It looks pretty nice. See the following:
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true);