title: Android Navigation Drawer & Dialog
body: <p><br/>
  is it possible to display an AlertDialog/DialogFragment and keep the Navigation Drawer open?<br/>
  I have tried an Alert Dialog and a dialog fragment, but the drawer closes abruptly.</p>
  
  <p>AlertDialog:</p>
  
  <pre><code>    new AlertDialog.Builder(this)
     .setTitle("Title")
     .setMessage("Message")
     .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
           // ...
        }
     })
     .setIcon(android.R.drawable.ic_dialog_alert)
     .show();
  </code></pre>
  
  <p>DialogFragment:</p>
  
  <pre><code>public class NewTermDialogFragment extends DialogFragment {
  
  private EditText lectureName;
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
  
      LayoutInflater layoutInflater = getActivity().getLayoutInflater();
      View view = layoutInflater.inflate(R.layout.dialog_new_term, null);
  
      lectureName = (EditText) view.findViewById(R.id.lectureText);
  
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(view);
      builder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
  
          }
      });
  
      return builder.create();
  }
  }
  </code></pre>
  
  <p>Call:</p>
  
  <pre><code>FragmentManager fragmentManager = getFragmentManager();
  
  NewTermDialogFragment newTermDialogFragment = new NewTermDialogFragment();
  newTermDialogFragment.setCancelable(false);
  newTermDialogFragment.show(fragmentManager, "Dialog!");
  </code></pre>
  
  <p>Layout:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".MainActivity"&gt;
  
      &lt;LinearLayout xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;include layout="@layout/toolbar" /&gt;
  
          &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/container"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              tools:context=".RootActivity"
              tools:ignore="MergeRootFrame" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;fragment
          android:id="@+id/navigation_drawer"
          android:name="de.uni.kassel.studentenapp.fragments.NavigationDrawerFragment"
          android:layout_width="@dimen/navigation_drawer_width"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          tools:layout="@layout/fragment_navigation_drawer" /&gt;
  
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>