监听自定义对话框的控件
private void showDialog5(){ LayoutInflater inflater=LayoutInflater.from(this); View view=inflater.inflate(R.layout.dialog_layout,null); AlertDialog.Builder builder=new AlertDialog.Builder(this); builder.setTitle("自定义对话框"); //设置标题 builder.setIcon(R.drawable.ic_launcher); //设置标题图标 builder.setView(view); //创建dialog final Dialog dialog=builder.create(); Button bt = (Button) view.findViewById(R.id.bt); final EditText et = (EditText) view.findViewById(R.id.editText); bt.setOnClickListener(new android.view.View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String str=et.getText().toString(); Toast.makeText(MainActivity.this,"提交的内容是"+str,1000).show(); dialog.dismiss(); } }); //显示dialog dialog.show(); }
只能帮到这里了,加油。