Android-对话框
来源:互联网 发布:用python编写99乘法表 编辑:程序博客网 时间:2024/06/07 02:34
Android-对话框
一 实现对话框的步骤Dialog1 常用对话框:
AlertDialog(弹出对话框)
DatePickerDialog(日期选择对话框)
TimePickerDialog(时间选择对话框)
构建方法:
AlertDialog _alertDialog = new AlertDialog.Builder(MyContentMenuActivity.this).create();builder设计模式适用于,构造参数较多的时候
2 建立步骤:
在onCreateDialog方法中建立一个AlertDialog.Builder实例
AlertDialog.set相应的属性
build实例.create()生成一个AlertDialog的实例
AlertDialog.show(),在show的时候也会create()
3 建立按钮:
在builder的时候调用setPositiveButton() and setNegativeButton()方法
二 自定义Dialog
1 直接利用基类Dialog的对象来setContentView来呈现不同的Dialog,可以看出Dialog与
Activity非常相似
2 利用AlertDialog创建的对象来直接setView即可实现自定义
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialog_signin, null))
3 如果想要自定义对话框,就用活动来作为对话框,而不是使用对话框API。
简单创建一个活动并在<activity>清单manifest元素设置主题为Theme.Holo.Dialog。
<activity android:theme="@android:style/Theme.Holo.Dialog" >
0 0
- Android对话框
- Android对话框
- android 对话框
- android 对话框
- Android对话框
- Android对话框
- Android对话框
- Android对话框
- android对话框
- Android对话框
- android对话框
- Android对话框
- Android对话框
- android对话框
- android对话框
- Android对话框
- android 对话框
- android 对话框
- 分支-08 高速公路超速处罚(15)
- 聊天机器人_远程接口javautil
- C++中RGB转换为ARGB
- html的编辑器 sublimetext2的使用及插件安装
- 认识自己——我的恐惧和悲观
- Android-对话框
- ThinkPHP 使用 PHPMaileer
- logger框架
- hdu 1050 (preinitilization or postcleansing, std::fill)
- MFC复习
- JFinal功能浅析
- 一元线性回归模型与最小二乘法及其C++实现
- LinkedIn Cubert安装指南
- Java程序员的好工具:通过json生成javabean(pojo)