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

 时间:2024-11-01 02:14:46

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警告对话框
热门搜索
薄饼的做法 华为手机怎么隐藏应用 汉堡的做法 粽子的做法和包法 白斩鸡的做法 任正非的女怎么姓孟 韭黄的做法 微信群怎么建立 石锅鱼的做法 表格中的斜线怎么弄