title: android action bar onNavigationItemSelected
body: <p>I'm developing for android 3+</p>
  
  <p>In my action bar i have a drop-down list(see <a href="https://stackoverflow.com/questions/9588810/how-to-hide-unhide-the-actionbar-list-on-android-3">how to hide/unhide the actionbar list on android 3?</a> for the dropdown i intend). The problem is i need to do a certain action when the user selects something, but Android calls onNavigationItemSelected() as soons as it draws the view, so no selection actually happened.</p>
  
  <p>How can i detect if the user actually pressed something and it is not a fake call from android ?</p>
  
  <pre><code>public class ListDittaListener implements OnNavigationListener{
  
      private BaseActivity activity;
  
      private ListDittaListener()
      {
  
      }
  
      public ListDittaListener(BaseActivity activity)
      {
          this.activity = activity;
      }
  
      @Override
      public boolean onNavigationItemSelected(int itemPosition, long itemId)
      {
          MyApp appState = ((MyApp)this.activity.getApplicationContext());
          appState.setDittaSelezionata( (int) itemId);
  
          SharedPreferences settings = this.activity.getSharedPreferences(MyApp.PREFS_NAME, 0);
          SharedPreferences.Editor editor = settings.edit();
          editor.putInt("ditta_id_selezionata", (int) itemId);
  
              ////////restart activity this.activity.recreate();
  
          return false;
      }
  
  }
  </code></pre>