title: Problem inflating custom view for AlertDialog in DialogFragment
body: <p>I'm trying to create a <code>DialogFragment</code> using a custom view in an <code>AlertDialog</code>. This view must be inflated from xml. In my <code>DialogFragment</code> class I have:</p>
  
  <pre><code>@Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      return new AlertDialog.Builder(getActivity())
          .setTitle("Title")
          .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, null))
          .setPositiveButton(android.R.string.ok, this)
          .setNegativeButton(android.R.string.cancel, null)
          .create();
  }
  </code></pre>
  
  <p>I have tried other inflation methods for <code>.setView()</code> such as:</p>
  
  <pre><code>.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, (ViewGroup) getView(), false))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, (ViewGroup) getTargetFragment().getView(), false))
  </code></pre>
  
  <p>After setting the target fragment in the fragment that is showing this dialog.</p>
  
  <p>All of these attempts to inflate my custom view result in the following exception:</p>
  
  <pre><code>E/AndroidRuntime(32352): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
  E/AndroidRuntime(32352):        at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:214)
  E/AndroidRuntime(32352):        at com.android.internal.app.AlertController.installContent(AlertController.java:248)
  E/AndroidRuntime(32352):        at android.app.AlertDialog.onCreate(AlertDialog.java:314)
  E/AndroidRuntime(32352):        at android.app.Dialog.dispatchOnCreate(Dialog.java:335)
  E/AndroidRuntime(32352):        at android.app.Dialog.show(Dialog.java:248)
  E/AndroidRuntime(32352):        at android.support.v4.app.DialogFragment.onStart(DialogFragment.java:339)
  E/AndroidRuntime(32352):        at android.support.v4.app.Fragment.performStart(Fragment.java:1288)
  E/AndroidRuntime(32352):        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:873)
  E/AndroidRuntime(32352):        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1041)
  E/AndroidRuntime(32352):        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:625)
  E/AndroidRuntime(32352):        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1360)
  E/AndroidRuntime(32352):        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:411)
  E/AndroidRuntime(32352):        at android.os.Handler.handleCallback(Handler.java:587)
  E/AndroidRuntime(32352):        at android.os.Handler.dispatchMessage(Handler.java:92)
  E/AndroidRuntime(32352):        at android.os.Looper.loop(Looper.java:132)
  E/AndroidRuntime(32352):        at android.app.ActivityThread.main(ActivityThread.java:4028)
  E/AndroidRuntime(32352):        at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(32352):        at java.lang.reflect.Method.invoke(Method.java:491)
  E/AndroidRuntime(32352):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
  E/AndroidRuntime(32352):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
  E/AndroidRuntime(32352):        at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>While if I try to use the <code>DialogFragment</code>'s <code>getLayoutInflator(Bundle)</code> like this:</p>
  
  <pre><code>.setView(getLayoutInflater(savedInstanceState).inflate(R.layout.dialog, null))
  </code></pre>
  
  <p>I get a <code>StackOverflowError</code>.</p>
  
  <p>Does anyone know how to inflate a custom view for an <code>AlertDialog</code> in a <code>DialogFragment</code>?</p>