title: java.lang.IllegalStateException when launching the Alert Dialog second time
body: <p><img src="https://i.stack.imgur.com/Hb2dz.png" alt="enter image description here"><br>
          I have created the Alert Dialog(with checkbox at the bottom), and launching it on the click of Preference. First time alert dialog launched successfully but second time following exception came :  </p>
  
  <pre><code>java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.  
  </code></pre>
  
  <p>MainActivity.java </p>
  
  <pre><code>final View checkBoxView = View.inflate(this, R.layout.checkbox, null);   /*to inflate dialog with checkbox */
  CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
  checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
          System.out.println("******** CheckBox Clicked *********");
          /* Save to shared preferences */
      }
  });
  checkBox.setText("Use by default for this action");
  
  Preference pref = (Preference) findPreference("preference");
          pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
              @Override
              public boolean onPreferenceClick(Preference arg0) {
                  final CharSequence[] items = {"BT Smart Settings by ABC",
                          "BT Smart Settings by XYZ",
                          "BT Smart Settings by DEFAULT"};
  
                  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                  builder.setTitle("Complete action using");
                  builder.setItems(items, new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int item) {
                          System.out.println("************* clicked-item :"+item);
  
                      }
                  });
                  builder.setView(checkBoxView);
                  AlertDialog alert = builder.create();
                  alert.show();
                  return false;
              }
          });
  </code></pre>
  
  <p>Any help in this regard will be well appreciated.</p>