title: DialogFragment showing AlertDialog with Adapter does not survive orientation change
body: <p>I have hit a wall on this one. My DialogFragment works well with all other dialogs I have except for the one that uses a customer Adapter. When changing orientation the second time I get a <code>java.lang.IllegalStateException: Fragment NewAlertDialog{447bc528} not attached to Activity</code> This is using the API 4+ Support package.</p>
  
  <p>It doesn't happen on the first orientation change, it always happens on the second, meaning it happens in this order with the dialog showing:</p>
  
  <ul>
  <li>Portrait -> Landscape -> Portrait -> java.lang.IllegalStateException</li>
  <li>Landscape -> Portrait -> Landscape -> java.lang.IllegalStateException</li>
  </ul>
  
  <p>Here is the dialog:</p>
  
  <pre><code>@Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
          final DialogItem[] items = {
                  new DialogItem(getString(R.string.test1), R.drawable.test1),
                  new DialogItem(getString(R.string.test2), R.drawable.test2),
              };
          ListAdapter adapter = new ArrayAdapter&lt;DialogItem&gt;(getActivity(),
              android.R.layout.select_dialog_item,
              android.R.id.text1,
              items){
                  public View getView(int position, View convertView, ViewGroup parent) {
                      View v = super.getView(position, convertView, parent);
                      TextView tv = (TextView)v.findViewById(android.R.id.text1);
                      tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                      int dp10 = (int) (10 * getResources().getDisplayMetrics().density + 0.5f);
                      tv.setCompoundDrawablePadding(dp10);
                      return v;
                  }
              };
          return new AlertDialog.Builder(getActivity())
                      .setTitle(R.string.title)
                      .setIcon(R.drawable.icon)
                      .setAdapter(adapter, new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int item) {
                              if (item == 0)
                                  doThis();
                              else
                                  doThat();
                          }
                      }).create();
  }
  </code></pre>
  
  <p>This is a DialogItem:</p>
  
  <pre><code>class DialogItem {
      public final String text;
      public final int icon;
      public DialogItem(String text, Integer icon) {
          this.text = text;
          this.icon = icon;
      }
      @Override
      public String toString() {
          return text;
      }
  }
  </code></pre>
  
  <p>I know it is a problem with containing an Adapter because if I remove the <code>.setAdapter()</code> call from <code>AlertDialog.Builder</code> then the problem goes away.</p>
  
  <p>Also odd is that there is NO PROBLEM on my ICS device. This only happens on the Gingerbread device I test on. Any help is greatly appreciated!</p>
  
  <p>Thank you!</p>
  
  <p>Matt.</p>