title: Adding action button using ADT 14
body: <p>I am a new developer of Android App and learning all tips from <a href="https://developer.android.com/training/index.html" rel="nofollow">Getting Started</a>. I'm now on the second stage phase 2 "Adding Action Button" and stuck with adding the actions to the action bar. Here is my current situation.</p>
  
  <ol>
  <li><p>MyfirstApp Manifest </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.myfirstapp"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="19" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.Holo.Light" &gt;
          &lt;activity
              android:name="com.example.myfirstapp.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;!-- A child of the main activity --&gt;
      &lt;activity
          android:name="com.example.myfirstapp.DisplayMessageActivity"
          android:label="@string/title_activity_display_message"
          android:parentActivityName="com.example.myfirstapp.MainActivity" &gt;
          &lt;!-- Parent activity meta-data to support 4.0 and lower --&gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="com.example.myfirstapp.MainActivity" /&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre></li>
  </ol>
  
  <p>2.main(menu).xml</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="ifRoom" /&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>3.MainActivity.java</p>
  
  <pre><code>package com.example.myfirstapp;
  
  import android.annotation.SuppressLint;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v7.app.ActionBarActivity;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.EditText;
  
  @SuppressLint("ValidFragment")
  public class MainActivity extends ActionBarActivity {
      public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_displaymessage);
  
      getActionBar().setDisplayHomeAsUpEnabled(true);
      // If your minSdkVersion is 11 or higher, instead use:
      // getActionBar().setDisplayHomeAsUpEnabled(true);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu items for use in the action bar
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.main_activity_actions, menu);
      return super.onCreateOptionsMenu(menu);
  }
  
  /** Called when the user clicks the Send button */
  public void sendMessage(View view) {
      Intent intent = new Intent(this, DisplayMessageActivity.class);
      EditText editText = (EditText) findViewById(R.id.edit_message);
      String message = editText.getText().toString();
      intent.putExtra(EXTRA_MESSAGE, message);
      startActivity(intent);
  }
  @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);
      }
  }
  
  private void openSettings() {
  
  }
  private void openSearch() {
  
  }
  
  /**
   * A placeholder fragment containing a simple view.
   */
  public class PlaceholderFragment extends Fragment {
  
      public PlaceholderFragment() {
      }
  
  @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_main, container, false);
          return rootView;
      }
      }
  }
  </code></pre>
  
  <p>I see two errors from MainActivity.java</p>
  
  <p>1.</p>
  
  <p><code>inflater.inflate(R.menu.main_activity_actions, menu);</code></p>
  
  <p>The method inflate(int, Menu) in the type MenuInflater is not applicable for the arguments (Object, Menu)</p>
  
  <p>2.</p>
  
  <p><code>case R.id.action_search:</code></p>
  
  <p>case expressions must be constant expressions</p>
  
  <p>I tried to figure out those 2 errors for couple days but I couldn't. Please help. </p>