title: getItemId mismatch with menu items
body: <p>I am trying to create an Android menu and using an onOptionsItemSelected(MenuItem item) I'm trying to figure out which menu item was selected. However, my menu items are off by 1.</p>
  
  <p>res/menu/settings.xml:</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item android:id="@+id/menuSettings" android:title="@string/settings" /&gt;
  &lt;item android:id="@+id/menuVisit" android:title="@string/visitPopup" /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>And my code looks like:</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) {
  // Handle item selection
  Log.v(LOG_TAG, "Menu button click!");
  Log.v(LOG_TAG, Integer.toString(item.getItemId()));
  Log.v(LOG_TAG, Integer.toString(R.id.menuSettings));
  
  switch (item.getItemId()) {
  case R.id.menuSettings:
      Log.v(LOG_TAG, "Trying to start Settings activity");
      startActivity(new Intent(this, SettingsActivity.class));
      return true;
  case R.id.menuVisit:
      Log.v(LOG_TAG, "Trying to start menuVisit activity");
      return true;
  default:
      Log.v(LOG_TAG, "Trying to start nondefined activity");
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The logcat result is:</p>
  
  <pre><code>Menu button click
  2131165200
  2131165201
  Trying to start nondefined activity
  </code></pre>
  
  <p>I am confused what I am doing wrong, as this piece of code did work at some time. But for unknown reasons this stopped working. As shown in the logcat output, the issue is that the 2 ID numbers do not match. They are off by one.</p>