How to show Indeterminate ProgressBar
when Refresh
button is pressed in ActionBarSherlock
and again show Refresh Button when ViewGroup on refreshed?
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
It seems like ActionBarSherlock doesn't provide specific method to animate a refresh MenuItem.
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 :
And when your refresh action is finished call :
Here is a sample of what your layout file refresh_menuitem.xml can have :
Here is a complete code:
One last note, in order to get the above code working you´ll need also call supportInvalidateOptionsMenu(). You can add that to the RefreshMyViewAsyncTask's onPreExecute() method.
Hope this helps to somebody.
Here is how you add this kind of indeterminate ProgressBar with a
ActionBarSherlock
object : (actually it's easier the other one but the progressBar is shown alone and not above aMenuItem
)1 - Put this line in the onCreate() method before the setContentView() call :
-> This line specify that you will use the indeterminate ProgressBar function.
2 - Enable the indeterminate ProgressBar by calling :
3 - Disable the indeterminate ProgressBar by calling :
Remark : Have a look in the sample folder of the ActionBarSherlock folder. I found this code in the following file : JakeWharton-ActionBarSherlock-9598f2b\samples\demos\src\com\actionbarsherlock\sample\demos\IndeterminateProgress.java