-
Notifications
You must be signed in to change notification settings - Fork 80
notification dialog API for Kotlin
vincent(朱志强) edited this page Sep 15, 2023
·
10 revisions
- 快速上手
- 详细API
SmartDialog.builderOfNotification()
.message("I'm a notification")
.build(activity)
.show()
val handle = SmartDialog.builderOfNotification()
.message("I'm a notification")
.build(activity)
//显示
handle.show()
//隐藏
handle.dismiss()
//是否正在显示
handle.isShowing()
SmartDialog.builderOfNotification()
.title("title")
.build(activity)
.show()
或者,
SmartDialog.builderOfNotification()
.titleResource(R.string.notification_title)
.build(activity)
.show()
SmartDialog.builderOfNotification()
//颜色,大小(单位sp),是否加粗
.titleStyle(Color.BLUE,18f,false)
.build(activity)
.show()
SmartDialog.builderOfNotification()
.message("I'm a notification")
.build(activity)
.show()
或者,
SmartDialog.builderOfNotification()
.messageResource(R.string.notification)
.build(activity)
.show()
SmartDialog.builderOfNotification()
//颜色,大小(单位sp),是否加粗
.messageStyle(Color.RED,14f,false)
.build(activity)
.show()
SmartDialog.builderOfNotification()
.confirmBtnLabel("确定")
.build(activity)
.show()
或者,
SmartDialog.builderOfNotification()
.confirmBtnLabelResource(R.string.confirm_label)
.build(activity)
.show()
SmartDialog.builderOfNotification()
//颜色,大小(单位sp),是否加粗
.confirmBtnLabelStyle(Color.BLUE,14f,false)
.build(activity)
.show()
回到目录导航
可以不设置监听器,默认监听器的效果是隐藏对话框。如想设置监听器,则通过函数confirmBtnListener:
SmartDialog.builderOfNotification()
.confirmBtnListener {
//do something
it.dismiss()
}
.build(activity)
.show()
SmartDialog.builderOfNotification()
//默认为true,也就是常见的配置,dialog显示时,周围背景是灰色蒙层
.dimBehind(true)
.build(activity)
.show()
SmartDialog.builderOfNotification()
//默认为true
.cancelable(true)
.build(activity)
.show()
SmartDialog.builderOfNotification()
//默认false
.cancelOnTouchOutside(false)
.build(activity)
.show()
SmartDialog.builderOfNotification()
.dialogShowListener {
//do something
}
.build(activity)
.show()
SmartDialog.builderOfNotification()
.dialogDismissListener {
//do something
}
.build(activity)
.show()
SmartDialog.builderOfNotification()
.dialogCancelListener {
//do something
}
.build(activity)
.show()
1