Android开发学习笔记-自定义对话框
2014-10-12 22:11
246 查看
系统默认的对话框只能显示简单的标题内容以及按钮,而如果想要多现实其他内容则就需要自定义对话框,下面是自定义对话框的方法。
1、先定义对话框的模版
2、之后将使用对话框模版将对话框重新渲染。
3、通过以上设置就可自定义对话框
1、先定义对话框的模版
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="300dp" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tv_title" android:layout_width="300dp" android:layout_height="30dp" android:textSize="22sp" android:text="设置中心" android:gravity="center"/> <EditText android:id="@+id/ed_password" android:layout_width="300dp" android:layout_height="50dp" android:textSize="22sp" android:hint="输入密码" /> <EditText android:id="@+id/ed_re_password" android:layout_width="300dp" android:layout_height="50dp" android:textSize="22sp" android:hint="重新输入密码" /> <LinearLayout android:layout_height="wrap_content" android:layout_width="300dp" android:orientation="horizontal" android:gravity="center_horizontal" > <Button android:id="@+id/btn_ok" android:text="确定" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_cancel" android:text="取消" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout>
2、之后将使用对话框模版将对话框重新渲染。
AlertDialog.Builder dialog = new Builder(this); View view = View.inflate(MainActivity.this, R.layout.set_password_dialog, null); dialog.setView(view); dialog.show();
3、通过以上设置就可自定义对话框
相关文章推荐
- android 学习笔记之20160307自定义对话框
- 学习笔记之Qt自定义对话框
- Android开发学习笔记:对话框浅析
- JSP2.0 tags自定义标签学习笔记
- IssueVision 学习笔记(二)-----为控件添加自定义属性和事件
- 用户自定义控件学习笔记
- 模式对话框和通用控件(『VC++技术内幕』学习笔记(9))
- 孙鑫VC学习笔记:第十五讲 (四) 编写一个基于MFC对话框的聊天程序
- 对话框学习笔记
- ant学习笔记—自定义Ant任务
- C#学习笔记(十六):使用打开保存文件对话框
- Silverlight学习笔记四:如何通过自定义ComboBox实现SelectedValue
- IssueVision 学习笔记(一)-----使用SoapHeader传递Web Serivices自定义的身份验证数据
- 异常处理与自定义异常学习笔记
- ASP.NET学习笔记--自定义验证控件的使用
- 孙鑫VC学习笔记:第十讲画图 创建设置画笔的对话框 并且可以预览效果
- C#学习笔记(十六):使用打开保存文件对话框
- 孙鑫VC学习笔记:第十五讲 编写一个基于MFC对话框的聊天程序
- Win32学习笔记——对话框资源
- GTK+图形化应用程序开发学习笔记(十二)—对话框构件、标尺构件