title: Android Open AlertDialog from Navigation Drawer
body: <p>I am using <code>NavigationDrawer</code> with some dummy <code>Fragments</code> in the menu and a <code>AlertDialog</code>. When I click to open the <code>AlertDialog</code> from the drawer I can close it with the no button but when I click to open it again it does not want to. </p>
  
  <p>I must then 1st switch to one of the other fragments in the drawer and then click on the dialog to open it.</p>
  
  <p>How to open it again after you close it without 1st switching to another menu item.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>@Override
  public boolean onNavigationItemSelected(MenuItem menuItem) {
  
      switch (menuItem.getItemId()) {
          case R.id.drawer_fragment_one:
              if (!menuItem.isChecked()) {
                  selectedIndex = COLLAPSING_TOOLBAR;
                  menuItem.setChecked(true);
                  getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                          new FragmentTabOne(), COLLAPSING_TOOLBAR_FRAGMENT_TAG).commit();
              }
              drawerLayout.closeDrawer(GravityCompat.START);
              return true;
  
          case R.id.drawer_fragment_two:
              if (!menuItem.isChecked()) {
                  selectedIndex = COLLAPSING_TOOLBAR;
                  menuItem.setChecked(true);
                  getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                          new FragmentTabTwo(), COLLAPSING_TOOLBAR_FRAGMENT_TAG).commit();
              }
              drawerLayout.closeDrawer(GravityCompat.START);
              return true;
  
          case R.id.drawer_alert_dialog:
              if (!menuItem.isChecked()) {
                  selectedIndex = ALERT_DIALOG;
                  menuItem.setChecked(true);
  
                  final AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                  dialog.setIcon(R.mipmap.ic_launcher);
                  dialog.setTitle(R.string.app_name);
                  dialog.setMessage(R.string.dialog_msg);
                  dialog.setPositiveButton(R.string.dialog_option_yes, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
  
                      }
                  });
  
                  dialog.setNegativeButton(R.string.dialog_option_no, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                          dialogInterface.dismiss();
                      }
                  });
  
                  dialog.show();
  
              }
              drawerLayout.closeDrawer(GravityCompat.START);
              return true;
  
          }
      return false;
  }
  </code></pre>