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警告对话框
热门搜索
运动的图片 正宗糖蒜的腌制方法 椒图带什么御魂 含维生素e的食物 左手无名指戴戒指什么意思 中老年运动装 66年属什么生肖 village什么意思 三个马念什么字 香港的市花是什么