title: android actionbar google tutorial
body: <p>i have done the android action bar google tutorial,
  but this is what i got:</p>
  
  <p><img src="https://i.stack.imgur.com/bXyAa.png" alt="enter image description here"></p>
  
  <p>the action setting button does not appear, and when the search button pressed nothing happens.
  can any one tell me what is wrong with the code?</p>
  
  <p>here is the files code..</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.example.actionbar;
  
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  
  public class MainActivity extends ActionBarActivity {
  
  public void openSearch(){
  
      System.out.println("TEST SEARCH");
  
  }
  public void openSettings(){
  
      System.out.println("TEST SETTINGS");
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.main_activity_actions, menu);
      return super.onCreateOptionsMenu(menu);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle presses on the action bar items
      switch (item.getItemId()) {
          case R.id.action_search:
              openSearch();
              return true;
          case R.id.action_settings:
              openSettings();
              return true;
          default:
              return super.onOptionsItemSelected(item);
      }
  }
  
  }
  </code></pre>
  
  <p><strong>MainActivityActions.xml</strong></p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:yourapp="http://schemas.android.com/apk/res-auto" &gt;
  &lt;!-- Search, should appear as action button --&gt;
  &lt;item android:id="@+id/action_search"
        android:icon="@drawable/ic_action_search"
        android:title="@string/action_search"
        yourapp:showAsAction="always"  /&gt;
  
  &lt;!-- Settings, should always be in the overflow --&gt;
  &lt;item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:showAsAction="never" /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.actionbar"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="7"
      android:targetSdkVersion="18" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/Theme.AppCompat.Light" &gt;
      &lt;activity
          android:name="com.example.actionbar.MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>