zoukankan      html  css  js  c++  java
  • android之自定义弹框

    step1 创建窗体

    final AlertDialog dialog =new Builder(this).create();

    step2 获取View

    View viewDialog =View.inflate(this, R.layout.userinfo_dialog_edit, null);
                final EditText txtUserName=(EditText)viewDialog.findViewById(R.id.txtUserName);
                final EditText txtBirthday=(EditText)viewDialog.findViewById(R.id.txtBirthday);
                final EditText txtPhoneNumber=(EditText)viewDialog.findViewById(R.id.txtPhoneNumber);
                final EditText txtAddress=(EditText)viewDialog.findViewById(R.id.txtAddress);
                txtUserName.setText(userDto.getUserName());
                txtBirthday.setText(userDto.getBirthday());
                txtPhoneNumber.setText(userDto.getPhoneNumber());
                txtAddress.setText(userDto.getAddress());
                Button btnSave =(Button)viewDialog.findViewById(R.id.btnSave);
                Button btnClose =(Button)viewDialog.findViewById(R.id.btnClose);
                btnSave.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View arg0) {
                        UserInfoDto dto =new UserInfoDto();
                        dto.setUserName(txtUserName.getText().toString());
                        dto.setBirthday(txtBirthday.getText().toString());
                        dto.setPhoneNumber(txtPhoneNumber.getText().toString());
                        dto.setAddress(txtAddress.getText().toString());
                        InsertOneTest(dto);
                    }
                });
                btnClose.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                    }
                });

    step3 show窗体

    dialog.setView(viewDialog, 0, 0, 0, 0);
    dialog.show();

  • 相关阅读:
    【转载】如何保证消息的顺序性?
    【转载】如何保证消息的可靠性传输?
    Java 浅拷贝与深拷贝的区别
    int 与 Integer 的区别
    Systemd
    如何查看systemctl启动服务的日志journalctl
    centos7安装killall命令
    关闭root用户的ssh登录
    react带ts创建
    ts-类型别名、类型断言
  • 原文地址:https://www.cnblogs.com/huangzhen22/p/4803487.html
Copyright © 2011-2022 走看看