浏览代码

Fixed https://github.com/afollestad/material-dialogs/issues/613

Aidan Follestad 10 年之前
父节点
当前提交
05c5ccc547
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 3 - 0
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -25,6 +25,7 @@ import android.text.TextUtils;
 import android.text.TextWatcher;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.ViewTreeObserver;
 import android.view.WindowManager;
 import android.widget.AdapterView;
@@ -898,6 +899,8 @@ public class MaterialDialog extends DialogBase implements
                 throw new IllegalStateException("You cannot use customView() with an input dialog");
             else if (this.progress > -2 || this.indeterminateProgress)
                 throw new IllegalStateException("You cannot use customView() with a progress dialog");
+            if (view.getParent() != null && view.getParent() instanceof ViewGroup)
+                ((ViewGroup) view.getParent()).removeView(view);
             this.customView = view;
             this.wrapCustomViewInScroll = wrapInScrollView;
             return this;