对话框show问题,需要removeView,

报的提示错误:

The specified child already has a parent. You must call removeView() on the child's parent first.

解决方法有两种

1.动态生成EditText

et1 = new EditText(this);
builder.setView(et1);

2. 放在另一个xml中,用inflater

LayoutInflater inflater = LayoutInflater.from(this);  
View textEntryView = inflater.inflate(R.layout.test1, null);
et1 = (EditText)textEntryView.findViewById(R.id.editText1);
builder.setView(textEntryView ); 注意这里是textEntryView ,不是et1

参考: http://www.cnblogs.com/shenbin/archive/2012/03/15/2398209.html

你可能感兴趣的:(对话框show问题,需要removeView,)