Get item view from ActionBar

Dmitriy Tarasov picture Dmitriy Tarasov · Feb 13, 2013 · Viewed 7.6k times · Source

I have an ActionBarSherlock with one menu item in my bar. When I'm call View item = findViewById(R.id.my_item);in activity's button onClick all works fine as expected. But when I try to do this in onCreate or onResume or even in onPostResume it is always null. I also tryed do this in onCreateOptionsMenu(Menu menu) after inflating my menu from resource, but without any succes.

Therefore I can't understand when actionbar items created and how to catch this moment?

Answer

Dmitriy Tarasov picture Dmitriy Tarasov · Feb 14, 2013

As it has been said here and here, getActionView returns the view that we sets in setActionView. Therefore, the only one way to customize action bar menu item described here