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警告对话框
热门搜索
践行是什么意思 右胸部上方里面隐隐作痛是什么原因引起的 太空生活 鼠标没反应怎么回事 如何选购二手车 遴选是什么意思 加班费如何计算 如何远程桌面连接 赛尔号乱斗怎么打 如何开通创业板