title: Calling DialogFragment from Fragment
body: <p>I am trying to call a DialogFragment from my Fragment class. I have an ImageView, and would like to call my DialogFragment class in the onClickListener of the ImageView I have set up.</p>
  
  <p>I am getting an error in the onClick with the code I have set up trying to call the DialogFragment.</p>
  
  <p>I am getting an error on "show" stating "The method show(FragmentManager, String) in the type DialogFragment is not applicable for the arguments (FragmentManager, String)" and an error on "new Instance" stating "The method newInstance() is undefined for the type MyDialogFragment"</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, 
    Bundle savedInstanceState)
  {
      final View v = inflater.inflate(R.layout.image_detail_fragment, 
        container, false);
  
      mImageView = (RecyclingImageView) v.findViewById(R.id.imageView);
      mImageView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
              //Here
              MyDialogFragment dialog = MyDialogFragment.newInstance();
              dialog.show(getFragmentManager(), "fragmentDialog");
          }
      });
  
      return v;
  }
  </code></pre>
  
  <p>DialogFragment class:</p>
  
  <pre><code>import android.app.AlertDialog;
  import android.app.Dialog;
  import android.app.DialogFragment;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.os.Bundle;
  
  class MyDialogFragment extends DialogFragment {
  
      Context mContext;
  
      public MyDialogFragment() {
          mContext = getActivity();
      }
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
          alertDialogBuilder.setTitle("Set Wallpaper?");
          alertDialogBuilder.setMessage("Are you sure?");
          //null should be your on click listener
          alertDialogBuilder.setPositiveButton("OK", null);
          alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
              }
          });
  
          return alertDialogBuilder.create();
      }
  
      public static MyDialogFragment newInstance() {
          MyDialogFragment = new MyDialogFragment;
          return f;
      }
  }
  </code></pre>