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警告对话框
热门搜索
怎么画动漫人物的眼睛 怎么提神 清宫表怎么看 项目概况怎么写 铁锅生锈怎么办 微信好友删除怎么找回 电子签名怎么做 加减号一起怎么打 手心热是怎么回事 竖线符号怎么打