I’m trying to display a progress bar instead of a refresh menu item in the action bar. However, when I currently press the refresh button, it disappears, but the progress bar replaces the action bar title, instead of appearing where the refresh button was.
These are my two .xml files:
-
The menu item:
<item android:id="@+id/menu_refresh" android:icon="@drawable/ic_menu_refresh" android:visible="true" android:orderInCategory="0" android:showAsAction="ifRoom|collapseActionView" android:actionLayout="@layout/action_progress_bar" android:title="@string/refresh" android:titleCondensed="@string/refresh"/> -
The progress bar layout:
<?xml version="1.0" encoding="utf-8"?> <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="32dp" android:layout_height="32dp" > </ProgressBar>
I found out what the problem is. In order for the progress bar to appear instead of the menu item, it must not have the collapseActionView flag. Removing it, and moving the logic to the code (along with using the easy setActionView method), did the trick