title: Adding a button to the Action Bar in Android?
body: <p>For some reason, I cannot get my button to appear on the Action Bar.  I have defined it in an XML file in /res/menu, along with inflating it and listening for an action.  The icon is present in /res/drawable-hdpi.  And nothing of interest shows in logcat. :(</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  &lt;item android:id="@+id/logout"
        android:icon="@drawable/logout"
        android:title="Logout"
        android:orderInCategory="100"
        android:showAsAction="always" /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>Code in main activity:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.main_activity_actions, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle presses on the action bar items
      switch (item.getItemId()) {
          case R.id.logout:
              //logout code
              return true;
          default:
              return super.onOptionsItemSelected(item);
          }
      }
      //rest of app
  }
  </code></pre>
  
  <p>I followed this question for my initial problem, and it didn't help. <a href="https://stackoverflow.com/questions/17425742/how-to-add-button-in-actionbarandroid">How to add button in ActionBar(Android)?</a></p>