安卓开发入门教程-UI控件_AlertDialog
程序开发
2023-09-08 19:57:17
关注 安卓007 ,免费获取全套安卓开发学习资料
什么是AlertDialog
AlertDialog是以提示框形式展示信息的UI控件,.
基础样例
效果图
代码
private fun showDialog() {AlertDialog.Builder(this).setTitle("对话框标题").setMessage("对话框内容").setIcon(R.mipmap.ic_launcher)//设置图标.setCancelable(true) //设置点击对话框以外区域是否让对话框消失//设置确定按钮.setPositiveButton("确定") { dialog, _ ->Toast.makeText(this, "你点击了确定", Toast.LENGTH_SHORT).show()dialog.dismiss()}//设置取消按钮.setNegativeButton("取消") { dialog, _ ->Toast.makeText(this, "你点击了取消", Toast.LENGTH_SHORT).show()dialog.dismiss()}.create().show()
}
基础样例完整源代码
https://gitee.com/cxyzy1/AlertDialogDemo
常用方法说明
安卓开发入门教程系列汇总
开发语言学习
Kotlin语言基础
UI控件学习系列
UI控件_TextView
UI控件_EditText
UI控件_Button
UI控件_ImageView
UI控件_RadioButton
UI控件_CheckBox
UI控件_ProgressBar
关注头条号,第一时间获取最新文章:
标签:
上一篇:
ant-desgin for vue. Modal组件修改样式无效问题
下一篇:
相关文章
-
无相关信息