Android中的AlertDialog遇到的错误

public void showAddIPCDialog() {
Log.i("ssssssssss","wwwwwwwwww");
LayoutInflater inflater = this.getActivity().getLayoutInflater();
Log.i("ssssssssssinflater",inflater+"");
//错误
// final View layout = inflater.inflate(R.layout.addipc, (ViewGroup) findViewById(R.id.addipc_dialog));//添加布局

//正确

final View layout = inflater.inflate(R.layout.addipc, null);//添加布局

Log.i("sssssssssslayout",layout+"");
EditText etName = (EditText) layout.findViewById(R.id.et_camera_name);
EditText edit = (EditText) layout.findViewById(R.id.sn);
EditText editps = (EditText) layout.findViewById(R.id.password);

new AlertDialog.Builder(this.getActivity()).setTitle("添加监控摄像头").setView(layout)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {

}
}).setNegativeButton("取消", null).show();
}

//总结:复制需谨慎
posted on 2017-09-19 21:21  巫山老妖  阅读(333)  评论(0编辑  收藏  举报