LinearLayout loginLayout = (LinearLayout) getLayoutInflater().inflate(R.layout.login, null);
new AlertDialog.Builder(this).setIcon(R.drawable.login).setTitle("用户登录").setView(loginLayout)
.setPositiveButton("登录", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int whichButton){
// 这里如果要拿到XML中的对话框的话仅仅用findviewbyid是不行的,在之前要使用开始得到 的VIEW,例如此题应当:
EditText myedittext = (EditText)loginLayout.findViewById(R.id.编辑框ID值);
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int whichButton){
// 取消用户登录,退出程序
}
}).show();