title: ActionBarSherlock: Programmatically show / hide Action Item buttons via a method call
body: <p>I am using ActionBarSherlock. I wish to be able to make two buttons appear in the Action Bar in response to a certain user operation. The user operation is completely unrelated to the Action Bar. The visibility of the buttons needs to be controlled by calling a method. Also, response to clicking those buttons shall be handled by my own application code. </p>
  
  <p>The buttons shall ideally look just like those that are created when defining menu items as Action Items using <code>android:showAsAction="ifRoom|withText"</code>, as illustrated <a href="http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems">here</a>. </p>
  
  <p>My problem is that as far as I can tell, the standard <code>ActionBar</code> API provides no such mechanism to show or hide Action Item buttons at will, and the only time that the menu items can be defined is within <code>onCreateOptionsMenu()</code> which is of course called by the system. </p>
  
  <p>My belief is that the only way I'm going to add buttons like this and show / hide them at will is to create a custom layout for them and make use of <code>.setCustomView()</code> to place them into the Action Bar. Would people generally agree with that, or is there something I have missed?</p>
  
  <p>If I do go down the route of using <code>.setCustomView()</code>, I would like my buttons to look identical to Action Item buttons that ActionBarSherlock displays for a menu item that has the attribute <code>android:showAsAction="ifRoom|withText"</code>. To do this, can anyone advise me which particular theme, style, or layouts from within the ActionBarSherlock library I should make use of? I have already tried to use <code>R.layout.abs__action_menu_item_layout</code>, but attempting to inflate this layout produces an exception relating to a <code>colorStateList</code> when attempting inflation of the <code>CapitalizingButton</code> that the layout contains. </p>