AlertDialog的create和show
来源:互联网 发布:ubuntu 16.04与16.10 编辑:程序博客网 时间:2024/05/04 02:58
《疯狂Android讲义》中,对话框的设置用builder,对话框的显示需要先builder.create后builder.show,不知道是不是版本问题,不过从源代码来看,如果builder.show了,就不用调用builder.create。
注释中说到:create:用builder提供的参数来创建一个AlertDialog。调用该方法并不会显示对话框。如果不需要附加操作(processing),则调用show将会代替create和显示对话框。
show:创建对话框并立即显示。
所以如果创建对话框后还需要调整,则可以先create,再show,如果不需要调整,则可以直接show。
AlertDialog.show() : 1)final AlertDialog dialog = builder.create();
2)(AlertDialog)dialog.show();
/** * Creates an {@link AlertDialog} with the arguments supplied to this * builder. * <p> * Calling this method does not display the dialog. If no additional * processing is needed, {@link #show()} may be called instead to both * create and display the dialog. */ public AlertDialog create() { // Context has already been wrapped with the appropriate theme. final AlertDialog dialog = new AlertDialog(P.mContext, 0, false); P.apply(dialog.mAlert); dialog.setCancelable(P.mCancelable); if (P.mCancelable) { dialog.setCanceledOnTouchOutside(true); } dialog.setOnCancelListener(P.mOnCancelListener); dialog.setOnDismissListener(P.mOnDismissListener); if (P.mOnKeyListener != null) { dialog.setOnKeyListener(P.mOnKeyListener); } return dialog; } /** * Creates an {@link AlertDialog} with the arguments supplied to this * builder and immediately displays the dialog. * <p> * Calling this method is functionally identical to: * <pre> * AlertDialog dialog = builder.create(); * dialog.show(); * </pre> */ public AlertDialog show() { final AlertDialog dialog = create(); dialog.show(); return dialog; }
2 0
- AlertDialog的create和show
- AlertDialog.Builder和AlertDialog之间的关系
- mysql的 show status 和 show variables
- MySQL show create table
- SHOW CREATE TABLE table_name
- show create table ‘tablename’
- Android: Show AlertDialog from Service
- mysql的sql_quote_show_create与SHOW CREATE TABLE命令介绍
- Oracle如何实现类似MySQL的show create table,show index的功能
- DialogFragment和AlertDialog的使用
- PopupWindow和AlertDialog的区别
- AlertDialog的种类和使用方法
- AlertDialog和AlertDialog.Builder
- 关于AlertDialog中不可思议的dialog.show()异常出错的问题的解决
- ShowDialog和Show的区别
- show和showdialog的区别
- show和showmodal的区别
- Form的show()和showDialog()
- OPENCV常见错误(一)
- ECharts3.0 强大的统计图
- 广播接收者
- JS函数集合大全
- 动态添加综合布局---动态添加控件及将某XML动态加入到Activity显示(续)
- AlertDialog的create和show
- 1.3线程停止
- 颠覆性创新
- JS函数调用的四种方法
- 用PocketSphinx做离线命令词识别
- 双三次插值算法的OpenGL实现
- 平定igb之“乱”
- 坐标下降优化算法
- Matlab中legend的用法