-
-
Notifications
You must be signed in to change notification settings - Fork 9
DialogClickListener
Marc Auberer edited this page Sep 12, 2020
·
4 revisions
Displays an AlertDialog when the associated preference item was clicked.
Yes/No dialog with icon with ButtonResultCallback
TextPref {
title = "Dialog"
summary = "Tap to show yes/no dialog"
onClick = DialogClickListener(this@MainActivity) {
title = "Test"
message = "This is a test"
icon = R.drawable.settings
cancelable = false
type = DialogClickListener.Type.YES_NO
}
}
...
override fun onDialogButtonClicked(button: DialogClickListener.Button) {
when(button) {
DialogClickListener.Button.POSITIVE -> {
Toast.makeText(this, "Clicked yes", Toast.LENGTH_SHORT).show()
}
DialogClickListener.Button.NEGATIVE -> {
Toast.makeText(this, "Clicked no", Toast.LENGTH_SHORT).show()
}
}
}
OK dialog without icon and callback
TextPref {
title = "Dialog"
summary = "Tap to show ok dialog"
onClick = DialogClickListener("Test", "This is a test", DialogClickListener.Type.OK)
}
© Marc Auberer 2020-2023