1

I want to apply a rotate Animation to an action in my ActionBar. For the ActionBar I´m using ActionBarSherlock.

My problem is, that in all Solutions I found (e.g. Animated Icon for ActionItem) they are getting the MenuItem which shall be animated in onOptionsItemSelected(MenuItem item).

But I want to be able to start the animation even BEFORE some action is selected. So how can I get the MenuItem?

Community
  • 1
  • 1
anonymous
  • 1,141
  • 3
  • 11
  • 20

1 Answers1

7

Call findItem() on the Menu supplied to onCreateOptionsMenu().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • The problem is onCreateOptionsMenu() ist called AFTER onCreate. But the Thread which starts the animation and started in onCreate is faster than onCreateOptionsMenu. So is there an other solution? – anonymous Mar 28 '12 at 00:38
  • 1
    You can't animate something that's not there. Even if onCreateOptionsMenu() is called after onCreate() (is that contract true in all cases?), your Menu hasn't been inflated, and so there are no MenuItems to animate. Mark's solution is correct. – James Mar 28 '12 at 07:52
  • 2
    @anonymous: Start your thread in `onCreateOptionsMenu()`. Nobody is forcing you to start it in `onCreate()`. – CommonsWare Mar 28 '12 at 11:07
  • is it possible to animate actionBar's app logo? – Apurva Feb 11 '15 at 16:28