Android学习笔记:[4]AlertDialog警告对话框

 时间:2026-02-15 10:59:07

1、新建一个Android Application Project:

Android学习笔记:[4]AlertDialog警告对话框

2、将这个Android Application Project命名为:AertDialog

Android学习笔记:[4]AlertDialog警告对话框

3、打开其中的MainActivity:

Android学习笔记:[4]AlertDialog警告对话框

4、首先声明成员变量:

Android学习笔记:[4]AlertDialog警告对话框

5、设置提示信息,setPositiveButton():给对话框添加”Yes”按钮,

setNegativeButton():给对话框添加”No”按钮:,确定按钮:

Android学习笔记:[4]AlertDialog警告对话框

6、调用Builder的create( )方法,

调用AlertDialog的show( )方法显示对话框:

Android学习笔记:[4]AlertDialog警告对话框

7、activity.xml中的布局情况:

Android学习笔记:[4]AlertDialog警告对话框

8、在虚拟机中运行一下,右击该Project选择“运行方式“,选择”Android Application“:

Android学习笔记:[4]AlertDialog警告对话框

9、点击按钮,则出现对话框,选择不同选项,字符出现不同情况:

Android学习笔记:[4]AlertDialog警告对话框

Android学习笔记:[4]AlertDialog警告对话框

Android学习笔记:[4]AlertDialog警告对话框

  • 如何修改文件的扩展名\如何隐藏或显示扩展名
  • 如何显示所有文件类型的扩展名?
  • 如何复制文件或文件夹路径
  • if-else_if 判断否则与判断
  • excel如何添加工作簿连接快捷键
  • 热门搜索
    老公不在你们都是怎么解决 林肯汽车怎么样 福建师范大学怎么样 印花税怎么计算 怎么增高 脸上过敏了怎么办 我的世界熔炉怎么做 pdf怎么加密 伤口化脓怎么办 台式电脑怎么调亮度