最简单的android弹出对话框
来源:互联网 发布:简单的数据分析方法 编辑:程序博客网 时间:2024/05/29 02:36
弹出一个消息框
new AlertDialog.Builder(this) .setTitle("确认") .setMessage("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk") .setPositiveButton("是", null) .show();
带确认和取消按钮的对话框
<span style="white-space:pre"></span>new AlertDialog.Builder(self) <span style="white-space:pre"></span>.setTitle("确认")<span style="white-space:pre"></span>.setMessage("确定吗?")<span style="white-space:pre"></span>.setPositiveButton("是", null)<span style="white-space:pre"></span>.setNegativeButton("否", null)<span style="white-space:pre"></span>.show();注意到,这里有两个null参数,这里要放的其实是这两个按钮点击的监听程序,由于我们这里不需要监听这些动作,所以传入null值简单忽略掉,但是实际开发的时候一般都是需要传入监听器的,用来响应用户的操作。
一个可以输入文本的对话框
<span style="font-size:18px;"><span style="white-space:pre"></span>new AlertDialog.Builder(self)<span style="white-space:pre"></span>.setTitle("请输入")<span style="white-space:pre"></span>.setIcon(android.R.drawable.ic_dialog_info)<span style="white-space:pre"></span>.setView(new EditText(self))<span style="white-space:pre"></span>.setPositiveButton("确定", null)<span style="white-space:pre"></span>.setNegativeButton("取消", null)<span style="white-space:pre"></span>.show();</span>
单选框与多选框
<span style="font-size:18px;"> <span style="white-space:pre"></span>new AlertDialog.Builder(self)<span style="white-space:pre"></span>.setTitle("请选择")<span style="white-space:pre"></span>.setIcon(android.R.drawable.ic_dialog_info) <span style="white-space:pre"></span>.setSingleChoiceItems(new String[] {"选项1","选项2","选项3","选项4"}, 0, <span style="white-space:pre"></span> new DialogInterface.OnClickListener() { <span style="white-space:pre"></span> public void onClick(DialogInterface dialog, int which) { <span style="white-space:pre"></span> dialog.dismiss(); <span style="white-space:pre"></span> }<span style="white-space:pre"></span> }<span style="white-space:pre"></span>)<span style="white-space:pre"></span>.setNegativeButton("取消", null)<span style="white-space:pre"></span>.show();</span><span style="font-size:24px;"></span>
<span style="font-size:18px;"><span style="white-space:pre"></span>new AlertDialog.Builder(self)<span style="white-space:pre"></span>.setTitle("多选框")<span style="white-space:pre"></span>.setMultiChoiceItems(new String[] {"选项1","选项2","选项3","选项4"}, null, null)<span style="white-space:pre"></span>.setPositiveButton("确定", null) <span style="white-space:pre"></span>.setNegativeButton("取消", null)<span style="white-space:pre"></span>.show();</span>
列表对话框
<span style="white-space:pre"></span>new AlertDialog.Builder(self)<span style="white-space:pre"></span>.setTitle("列表框")<span style="white-space:pre"></span>.setItems(new String[] {"列表项1","列表项2","列表项3"}, null)<span style="white-space:pre"></span>.setNegativeButton("确定", null)<span style="white-space:pre"></span>.show()
图片框
ImageView img = new ImageView(self);img.setImageResource(R.drawable.icon);new AlertDialog.Builder(self).setTitle("图片框").setView(img).setPositiveButton("确定", null).show();
更多点击打开链接
0 0
- 最简单的android弹出对话框
- Android简单弹出对话框AlertDialog的使用
- 最简单的对话框
- android开发 点击按钮弹出对话框的简单实现
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 动态修改ListView
- 【Android基础学习】Android权限
- [self presentViewController:vc animated:YES completion:nil]的相互引用问题
- icare3.0程序中关于诊疗卡号长度的设置-------运维日志16
- Hbase笔记 - 快速安装(单机模式)
- 最简单的android弹出对话框
- linux下常用命令
- java最常用的设计模式之一外观模式
- Java 序列化与反序列化
- android monkey用法的介绍
- GatewayWorker教程2
- sqoop实战:sqlserver导入hbase命令
- 基于ARM_contexA9 led驱动编程
- 一个预防堕落的秘方