Android(安卓)AlertDialog ————普通对话框
16lz
2021-01-25
对话框没啥注意的,使用的时候,要主要上下文使用this
//弹出一个普通对话框 private void showNormalDialog() { //[1]构造对话框的实例 AlertDialog.Builder builder = new Builder(this); builder.setTitle("警告"); builder.setMessage("世界上最遥远的距离是没有网络"); //[2]设置确定和取消按钮 builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.out.println("111111"); } }); builder.setNegativeButton("取消",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.out.println("2222"); } }); //[3]展示对话框 和toast一样 一定要记得show出来 builder.show(); }
更多相关文章
- 开源项目之Android-GL(OpenGL 编程)
- Android(安卓)ViewPager实例代码介绍2。
- Android中Intent的几种使用方法
- Android中设计模式无处不在之单例模式
- 分析(Android下的任务和Activity栈)
- android 调用系统自带的设置时间日期对话框
- android中关于tools:context="activity name"解惑
- getLayoutInflater().inflate
- android volley 调用webService