title: DialogFragment.show() throws NullPointerException
body: <p>I'm making my first major Android app, and I'm trying to show a dialog in an <code>ActionBarActivity</code>. I've created a subclass of DialogFragment:</p>
  
  <pre><code>public class QuestionFragment extends DialogFragment {
  private final String[] CHOICES = {"More than once per day","Once per day","Less often"};
  
  public QuestionFragment() {
      //Required empty constructor
  }
  
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setTitle("How often do you take this medication?")
              .setItems(CHOICES, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                      //options for int which go here
                  }
              });
      return builder.create();
  }
  }
  </code></pre>
  
  <p>I try to use the show method in a very similar way to how the Android developer tutorials explain it. The dialog is supposed to come up when a button is clicked:</p>
  
  <pre><code>public void toAdd(View view) {
      QuestionFragment dialog = new QuestionFragment();
      dialog.show(dialog.getFragmentManager(),"question");
  }
  </code></pre>
  
  <p>When I try this, I get:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.FragmentTransaction android.app.FragmentManager.beginTransaction()' on a null object reference
          at android.app.DialogFragment.show(DialogFragment.java:228)
          at gianttine.rescription.TodayMeds.toAdd(TodayMeds.java:49)
          ...
  </code></pre>
  
  <p>I've also tried changing <code>(dialog.getFragmentManager(),"question");</code> to <code>(getFragmentManager(),"question");</code>, and I've also tried making a <code>FragmentManager</code> object before passing it into <code>show()</code>.</p>
  
  <p>As I'm new to Android development, I may have some poor design choices in that code, but I am looking to find out why there is an exception and what I need to do to make the dialog show properly.</p>