自定义的对话框弹窗 AlertDialog
来源:互联网 发布:软件测试高级工程师 编辑:程序博客网 时间:2024/06/04 23:18
1、先定义一个xmL文件用于,用于填充成View对象;
2,得到 AlertDialog.builder对象; AlertDialog.Builder builder = new AlertDialog.Builder(this);
3,创建一个dialog; AlertDialog dialog = builder.create();
4;填充inflate View对象; View view = View.inflate(this, R.layout.dialog_set_password, null);
5;用Dialog 设置 View对象; dialog.setView(view); //将自定义的View 显示在对话框中。
6;显示 弹窗, 自定义的View dialog.show(); //要将dialog 的设置show显示。
//在低版本中会出现,带黑边的对话框,消除黑边的办法 如下,边距设为0;
dialog.setView(view, viewSpacingLeft, viewSpacingTop, viewSpacingRight, viewSpacingBottom);
android:inputType="textPassword" //以密码形式显示。 password 过时了;
这种方法出现的问题是,真机测试时对话框显示的尺寸很小;
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.create();// View view = View.inflate(this, R.layout.dialog_set_password, null);// dialog.setView(view, 0, 0, 0, 0); // 将自定义的View 显示在对话框中。 dialog.show(); // 要将dialog 的设置show显示。
改变显示对话框的尺寸方法:
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.create(); dialog.setContentView(R.layout.dialog_set_password); WindowManager.LayoutParams wlp = dialog.getWindow().getAttributes(); //拿到窗口管理器 得到其属性值。 wlp.width = (int) (getWindowManager().getDefaultDisplay().getWidth()*0.8);// wlp.gravity = Gravity.CENTER; dialog.getWindow().setAttributes(wlp);
点击取消时,dialog 的隐藏;
dialog.dimiss();
TextUtils.isEmpty(password) //判断 Returns true if the string is null or 0-length.如果字符串为null,或者长度为0.
- 自定义的对话框弹窗 AlertDialog
- 自定义 Android 对话框 (AlertDialog) 的样式
- 完全自定义Android对话框AlertDialog的实现
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 完全自定义Android对话框AlertDialog的实现
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义个性化的AlertDialog退出应用对话框
- Android的AlertDialog详解 自定义对话框
- 自定义 Android 对话框 (AlertDialog) 的样式
- AlertDialog自定义弹出对话框
- C语言 链表
- java中采用集合使用pull解析xml文件格式的方法
- Java源码阅读-HashMap
- OC 基础的 10个常用方法
- 父类子类相互转化的内存关系
- 自定义的对话框弹窗 AlertDialog
- h5学习笔记: css布局案例练习
- Swift-->GCD,NSThread,NSBlockOperation多线程使用(主线程回调)
- Jquery学习笔记
- git命令行学习思路总结
- git 的分支体系命令汇总
- Java源码阅读-List
- nodejs 全局变量和方法,以及console使用
- vim 学习总结