Open SalomonBrys opened 7 years ago
A much needed feature
Before the new feature add to the library, you can try this:
val pwAlert = activity.alert(Appcompat) {
titleResource = R.string.my_message
messageResource = R.string.my_message
okButton {}
}.build()
pwAlert.setCancelable(false)
pwAlert.setCanceledOnTouchOutside(false)
pwAlert.show()
@doitlite What Appcompat here? please explain more about it
UPDATE: // Appcompat-v7 (only Anko Commons) compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version" Use this for Appcompat (alert.build() returns android.support.v7.app AlertDialog)
In version 0.9 I was able to call cancellable(false)
. It was removed from builder in 0.10 I wonder if there was a reason for that or was it forgotten during refactoring. It should be easy to restore if there is no reason behind it.
Hi , You can use after ".show()" .setCancelable(false) for example -> alert("Body") { title = "Title" positiveButton("ok") { } }.show().setCancelable(false)
https://gist.github.com/BurakDizlek/4b026b3c8a736987902a7e65f73dc6da
doitlite
is correct:
val pwAlert = activity.alert(Appcompat) {
titleResource = R.string.my_message
messageResource = R.string.my_message
okButton {}
}.build().apply {
setCancelable(false)
setCanceledOnTouchOutside(false)
}.show()
I want to save dialog after screen rotation. but @doitlite and @Zhuinden don`t helps. I hope the best way is to use ViewModel.
val errorObservable: LiveData<SignInResult>
observe(errorObservable, ::handleError)
private fun handleError(error: Any?) {
if (error == null) {
return
}
activity.alert(Appcompat) {
titleResource = R.string.title
messageResource = R.string.message
okButton { mSignInViewModel.onErrorClosed() }
}.build().apply {
setCancelable(false)
setCanceledOnTouchOutside(false)
}.show()
}
There is currently no way to create an alert with the
alert
function and set the dialog to be non cancelable. I am "forced" to revert to java style creation when I need a non cancelable dialog.BTW, it would also be great if there was a way to access the
AlertDialog.Builder
.