title: Displaying second dialog from button click in first dialog closes first dialog
body: <p>In my app, I'm using an <code>AlertDialog</code> with a custom view.  This view contains a couple of <code>EditText</code>s and a few other things.  There are some listeners attached to the <code>EditText</code>s that perform whatever functionality is needed.</p>
  
  <p>On the button click of the dialog, I am performing some validation on the data entered into the <code>EditText</code>s and display another <code>AlertDialog</code> if the data is invalid.  Once that (second) dialog is closed, I want to remain on the main dialog (with the custom view), but for some reason that dialog is closed before my second dialog is shown.  How can I keep the original (custom view) dialog still open under the second dialog?</p>
  
  <p>Here's my (simplified) code:</p>
  
  <pre><code>final EntryPanel panel = new EntryPanel(OrderActivity.this);
  
  AlertDialog dlg = new AlertDialog.Builder(OrderActivity.this)
      .setCancelable(true)
      .setView(panel)
      .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              final int id = pePanel.getProductId();
              if(!isValidProduct(id)) {
  
                  new AlertDialog.Builder(OrderActivity.this)
                      .setMessage(R.string.error_unknown_product)
                      .setCancelable(true)
                      .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
  
                          @Override
                          public void onClick(DialogInterface dlg2, int which) {
                              dlg2.cancel();
  
                          }
                      })
                      .show();
              }
              else {
                  processProductEntry(id);
                  dialog.dismiss();
              }
          }
      })
      .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              dialog.cancel();
          }
      }).show();
  </code></pre>