zoukankan      html  css  js  c++  java
  • Android学习—自定义对话框Dialog

        /**
         * 自定义的对话框Custom_Dialog
         */
        private void showDialog() {
            
            // 获取自定义布局  
            LayoutInflater inflater = LayoutInflater.from(MainActivity.this);  
            View view = inflater.inflate(R.layout.customDialog, null);
            //View view = View.inflate(this, R.layout.custom_Dialog, null);
            // 创建对话框,使用自定义样式  
            Dialog dialog = new Dialog(this,R.style.customDialog);  
            // 点击事件监听处理
            et_pwd = (EditText) view.findViewById(R.id.et_normal_entry_pwd);        
            Button bt_normal_ok = (Button) view.findViewById(R.id.bt_normal_dialog_ok);
            Button bt_normal_cancle =  (Button) view.findViewById(R.id.bt_normal_dialog_cancle);
            bt_normal_ok.setOnClickListener(this);
            bt_normal_cancle.setOnClickListener(this);
            // 添加布局到对话框  
            dialog.setContentView(view);  
            // 设置对话框显示属性  
            Window dialogWindow = dialog.getWindow();  
            WindowManager.LayoutParams params = dialogWindow.getAttributes();  
            dialogWindow.setGravity(Gravity.BOTTOM); // 对话框显示方位  
            dialogWindow.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); // 背景变暗  
            params.x = 0; // 基于显示方位的水平偏移量  
            params.y = 0; // 基于显示方位的垂直偏移量  
            params.width = LayoutParams.FILL_PARENT; // 水平填充效果  
            params.height = LayoutParams.WRAP_CONTENT; // 垂直填充效果  
            params.dimAmount = 0.7f; // 背景黑暗度  
            dialogWindow.setAttributes(params);  
            dialog.show();  // 显示对话框
            
        }
  • 相关阅读:
    Python之pexpect详解
    Python之NMAP详解
    Python之正则表达式
    Python之面向对象-反射
    Python之元类详解
    Python之Django基本命令
    Python之Django的Model详解
    使用request+Beautiful爬取妹子图
    Django中settings设计模式(单例模式)
    六、Django之表单和类视图-Part 4
  • 原文地址:https://www.cnblogs.com/shuaiwen/p/3205264.html
Copyright © 2011-2022 走看看