-
Notifications
You must be signed in to change notification settings - Fork 80
acknowledge dialog API for Java
vincent(朱志强) edited this page Sep 15, 2023
·
3 revisions
- 快速上手
- 详细API
SmartDialog.builderOfAcknowledge()
.message("are you sure?")
.confirmBtnListener(new ConfirmBtnListener() {
@Override
public void onConfirmBtnClicked(DialogInterface dialog) {
dialog.dismiss();
//do something
}
})
.build(activity)
.show();
监听器可用lambda简写,
SmartDialog.builderOfAcknowledge()
.message("are you sure?")
.confirmBtnListener((ConfirmBtnListener) dialog -> {
dialog.dismiss();
//do something
})
.build(activity)
.show();
AcknowledgeDialogFacade.Handle handle = SmartDialog.builderOfAcknowledge()
.message("are you sure?")
.confirmBtnListener((ConfirmBtnListener) dialog -> {
dialog.dismiss();
//do something
})
.build(activity);
//显示
handle.show();
//隐藏
handle.dismiss();
//是否正在显示
handle.isShowing();
SmartDialog.builderOfAcknowledge()
.title("title")
.build(activity)
.show();
或者,
SmartDialog.builderOfAcknowledge()
.titleResource(R.string.acknowledge_title)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//颜色,大小(单位sp),是否加粗
.titleStyle(Color.BLUE,18f,false)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.message("are you sure?")
.build(activity)
.show();
或者,
SmartDialog.builderOfAcknowledge()
.messageResource(R.string.acknowledge_message)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//颜色,大小(单位sp),是否加粗
.messageStyle(Color.RED,14f,false)
.build(activity)
.show();
回到目录导航
单位秒,禁用若干秒后启用,禁用期间无法点击确认按钮,一般用于提示用户慎重操作。
SmartDialog.builderOfAcknowledge()
.message("开启开发者模式?")
.delayToConfirm(5)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.confirmBtnLabel("确定")
.build(activity)
.show();
或者,
SmartDialog.builderOfAcknowledge()
.confirmBtnLabelResource(R.string.confirm_label)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//颜色,大小(单位sp),是否加粗
.confirmBtnLabelStyle(Color.BLUE,14f,false)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.confirmBtnListener(new ConfirmBtnListener() {
@Override
public void onConfirmBtnClicked(DialogInterface dialog) {
//do something
dialog.dismiss();
}
})
.build(activity)
.show();
或简写为,
SmartDialog.builderOfAcknowledge()
.confirmBtnListener((ConfirmBtnListener) dialog -> {
//do something
dialog.dismiss();
})
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.cancelBtnLabel("取消")
.build(activity)
.show();
或者,
SmartDialog.builderOfAcknowledge()
.cancelBtnLabelResource(R.string.cancel_label)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//颜色,大小(单位sp),是否加粗
.cancelBtnLabelStyle(Color.BLUE,14f,false)
.build(activity)
.show();
回到目录导航
可以不设置监听器,默认监听器的效果是隐藏对话框。如想设置监听器,则通过函数confirmBtnListener:
SmartDialog.builderOfAcknowledge()
.cancelBtnListener(new CancelBtnListener() {
@Override
public void onCancelBtnClicked(DialogInterface dialog) {
//do something
dialog.dismiss();
}
})
.build(activity)
.show();
或简写为,
SmartDialog.builderOfAcknowledge()
.cancelBtnListener((CancelBtnListener) dialog -> {
//do something
dialog.dismiss();
})
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//默认为true,也就是常见的配置,dialog显示时,周围背景是灰色蒙层
.dimBehind(true)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//默认为true
.cancelable(true)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
//默认false
.cancelOnTouchOutside(false)
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.dialogShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
//do something
}
})
.build(activity)
.show();
或者简写成,
SmartDialog.builderOfAcknowledge()
.dialogShowListener(dialog -> {
//do something
})
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.dialogDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
//do something
}
})
.build(activity)
.show();
或者简写成,
SmartDialog.builderOfAcknowledge()
.dialogDismissListener(dialog -> {
//do something
})
.build(activity)
.show();
SmartDialog.builderOfAcknowledge()
.dialogCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//do something
}
})
.build(activity)
.show();
或者简写为,
SmartDialog.builderOfAcknowledge()
.dialogCancelListener(dialog -> {
//do something
})
.build(activity)
.show();
1