LayoutInflater layoutInflater = LayoutInflater.from(DialogActivity.this); // 创建视图容器并设置上下文
final View view = layoutInflater.inflate(R.layout.dialog,null); // 获取list_item布局文件的视图
new AlertDialog.Builder(DialogActivity.this).setTitle("自定义布局").setView(view).setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
EditText editText = (EditText) view.findViewById(R.id.likeText);
Toast.makeText(DialogActivity.this, "您的爱好是:"+editText.getText(), Toast.LENGTH_SHORT).show();
}
}).setNegativeButton("取消", null).show();