Search code examples
androidactionbarsherlockactivity-lifecycleandroid-inflate

Get item view from ActionBar


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?


Solution

  • 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