title: How to open another activity with a button on the action bar?
body: <p>in my action bar I put a button that goes to another activity but the code that does not work I'm testing and the application fails.</p>
  
  <p>This is the code file menu (main.xml):</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  tools:context="com.hello.turidf.MainActivity" &gt;
  
  
  &lt;item
      android:id="@+id/action_about"
      android:icon="@drawable/ic_action_about"
      android:orderInCategory="100"
      android:title="@string/action_about"
      app:showAsAction="always"
      android:onClick="enterInfo" /&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>And this is the code of the Java file (MainActivity.java):</p>
  
  <pre><code>package com.hello.turidf;
  
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.content.Intent;
  
  
  public class MainActivity extends ActionBarActivity {
  
  @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.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_about) {
          Intent intent = new Intent(this, InfoActivity.class);
          startActivity(intent);
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>