Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android对话框传送数据

关于对话框AlertDialog中的编辑框Editview始终都是NULL,网上到处找啊找,断断续续一直到刚才才搞定!例如下面这个登陆对话框: 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();