Android对话框-AlertDialog
来源:互联网 发布:mac程序删除 编辑:程序博客网 时间:2024/05/17 15:17
刚刚接触到对话框内容,通过一些文档的查阅,做了以下笔记,以备忘!
1、普通对话框
public void showNormalDialog(){
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setIcon(图标位置); //设置图标
builder.setTitle("我是一个普通的对话框");//设置标题
builder.setMessage("请点击确定按钮");//设置提醒的消息
builder.setPositiveButton("确定", new DialogInterface.OnclickListener(){//设置下方确定取消按钮
public void onClick(DialogInterface dialogInterface,int i){
Toast.makeText(MainActivity.this,"点击了确定按钮",Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnclickListener(){
public void onClick(DialogInterface dialogInterface,int i){
Toast.makeText(MainActivity.this,"点击了取消按钮",Toast.LENGTH_SHORT).show();
}
});
builder.show();//最后一定要show出来,否则对话框不显示}
2、列表对话框
public void showDialog(){
AlertDialog.Builder builder=new AlertDialog.Builder(this);
final String[ ] colors={"黑色","白色","黄色"};//列表项
builder.setTitle("我是一个列表对话框");//标题
builder.setItems(colors,new DialogInterface.OnCliskListener(){//监听
public void onClick(DialogInterface dialogInterface,int i){
Toast.makeText(MainActivity.this,colors[i],Tosat.LENGTH_SHORT).show();
}
});
builder.show();
}
- Android中的对话框AlertDialog
- 【Android】对话框 AlertDialog
- Android对话框之AlertDialog
- Android 对话框 (AlertDialog & ProgressDialog)
- 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
- 关于Android 对话框 AlertDialog
- Python内置函数学习(6)-bool(x)
- 《C++应用程序性能优化》之程序内存
- 【CodeForces 118D】【DP】 Caesar's Legions 【n1种步兵n2种马兵,询问多少种排列方式使不超过k1种步兵相连k2种马兵相连】
- #include <sys/socket.h>找不到头文件
- ”360宣布停止个人云盘服务“回顾360的发展历程
- Android对话框-AlertDialog
- ACM文件读入debug
- linux网络编程之socket(五):tcp流协议产生的粘包问题和解决方案
- 基于地图的短信追踪小练习(5)对话框之item的添加
- MySQL语法复习--储存过程与储存函数
- 嵌入式常见笔试题总结
- pcl一些简单方法的使用
- 阿里云ECS用tutumcloud/haproxy做virtual host
- 第八周作业——三色球问题