3

We're running into a really painful issue with Honeycomb's ActionBar here, and I was wondering if anyone else has found a solution. The problem itself is quite simple:

We frequently trigger background tasks in Activity onCreate or onResume, since most of our screens must display data loaded from a Web service. While these tasks are running, we show the ActionBar's refresh spinner and animate it. The problem is: onCreate and onResume are executed before onCreateOptionsMenu is, so at the point where we start the task, the refresh spinner doesn't even exist. Hence, it won't animate.

I don't see any simple way around this. I guess we could keep the information about a task being spawned in onCreate, and as soon as the ActionBar becomes available, update it accordingly. But still, I can't believe a use case as common as this is so difficult to do with ActionBar?

2
  • Any progress on this? Your workaround seems like, well, a workaround.
    – theomega
    Feb 5, 2013 at 17:42
  • I kept using the workaround for lack of a better solution.
    – mxk
    Feb 5, 2013 at 18:42

1 Answer 1

0

So I tried using invalidateOptionsMenu as outlined in question How to update a menu item shown in the ActionBar?, but that didn't have any effect.

I ended up tracking pending updates to the action bar using a simple boolean flag. Whenever there are calls to refresh its state, I set the flag, then check and reset it once the bar is created and perform any pending updates. Works great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.