Android: In ICS, how to move ActionBarItem from ActionBar to options menu?
<p>I would like to be able to move an ActionBarItem from the ActionBar to the options menu, based on the context of my application.</p>

<p>The below Activity has 2 menu items.  1 is set to ALWAYS_SHOW in the ActionBar, the other is set to NEVER show in the ActionBar.  The layout for the Activity contains a single button.  When this button is clicked, the ActionBar button should move to the options menu (if it is showing in the ActionBar) or should move to the ActionBar (if it is in the options menu).  </p>

<p>This Activity works as expected on Honeycomb.  However, calling the MenuItem.setShowAsAction method has no effect in ICS.  MenuItem.setVisible does hide/show the ActionBar item in ICS, but it does not result in the item being moved to the options menu.  Any ideas how to do make this work in ICS?</p>

<pre><code>public class TempProjActivity extends Activity implements OnClickListener
{
    Button hideButton;
    MenuItem actionbarButton;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        hideButton = (Button) findViewById(R.id.showhidebutton);
        hideButton.setOnClickListener(this);

    }

    boolean visible = true;
    @Override
    public void onClick(View v)
    {
        if(visible)
        {
            actionbarButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
            visible = false;
        }
        else
        {
            actionbarButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            visible = true;
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.optionsmenu, menu);

        actionbarButton = menu.findItem(R.id.actionbarbutton);

        return super.onCreateOptionsMenu(menu);
    }
}


&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:id="@+id/actionbarbutton"
          android:icon="@drawable/ic_launcher"
          android:text="@string/button"
          android:showAsAction="always"/&gt;
       &lt;item 
           android:text="@string/extra"
          android:showAsAction="never"/&gt;
&lt;/menu&gt;


&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFFFF"
    android:orientation="horizontal" &gt;
    &lt;Button android:id="@+id/showhidebutton" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/&gt;
&lt;/FrameLayout&gt;
</code></pre>
