错误描述:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
贴代码吧:
public void onClick(View v) {
if(v.getTag().equals("hide1")||v.getTag() == "hide1"){
try{
EditText edit = new EditText(this);
new AlertDialog.Builder(this).setTitle("请输入序列号").setView(edit)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
device_id = edit.getText().toString();
editor = settings.edit();
editor.putString("device_id", device_id);
editor.commit();
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
}catch(Exception e){
e.printStackTrace();
}
}
}
把EditText new在里面就可以了~