title: Android Basic Tutorial Adding the Action Bar , error: R cannot be resolved to a variable
body: <p>Hi I am new to Android Programming and currently am learning the tutorial from this site:
  <a href="http://developer.android.com/training/basics/firstapp/starting-activity.html" rel="nofollow">http://developer.android.com/training/basics/firstapp/starting-activity.html</a></p>
  
  <p>The error message i received in my MainActivity.java is
  R cannnot be resolved to a variable</p>
  
  <p>code:</p>
  
  <pre><code>package com.example.myfirstapp1;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.View;
  import android.widget.EditText;
  
   public class MainActivity extends Activity {
  public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
       getActionBar().setDisplayHomeAsUpEnabled(true);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      //getMenuInflater().inflate(R.menu.main, menu);
      //return true;
  
      // 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);
  }
  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);
  }
  
   }
  </code></pre>
  
  <p>The error occurs at the following lines:
  setContentView(R.layout.activity_main);
  inflater.inflate(R.menu.main_activity_actions, menu);</p>
  
  <p>Please help</p>