2010.04.16————android 带输入框AlertDialog 第二次点击出现错误
错误描述:
[color=red]ERROR/AndroidRuntime(1394): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.[/color]
修改:
把
[color=red]放到case里面来 每次创建时 都去加载R.layout.login 生成新的view 暂时解决了这个问题[/color]
错误描述:
[color=red]ERROR/AndroidRuntime(1394): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.[/color]
修改:
case 3 :
final View v = LayoutInflater.from(MainActivity.this).inflate(R.layout.login, null);
new AlertDialog.Builder(MainActivity.this).setTitle("验证密码")
.setCancelable(true)
.setView(v)
.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println(((EditText)v.findViewById(R.id.password_edit)).getText().toString());
}
})
.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).create().show();
break;
把
final View v = LayoutInflater.from(MainActivity.this).inflate(R.layout.login, null);
[color=red]放到case里面来 每次创建时 都去加载R.layout.login 生成新的view 暂时解决了这个问题[/color]