Kotlin / anko

Pleasant Android application development
Apache License 2.0
15.88k stars 1.29k forks source link

Can't close Anko alert using "button" type #600

Open ajonno opened 6 years ago

ajonno commented 6 years ago

Does anyone know how I can close an Anko alert, but using a "button" which is embedded in a customView, AND, where isCancelable has been set = false ?

Here is the Kotlin code for this alert (I've left out a bunch of styles for clarity):

    myAlert = alert {
      customView {
         verticalLayout {
           ..image, textView etc. r here..
           ..
           button("OK") {
               onClick {
                //**HOW CAN I CLOSE THIS ALERT FROM HERE??
               }
           }
      }
    }
    myAlert.isCancelable = false
    myAlert.show()

I noticed that the "onClick" callback above is of type "CoroutineScope" which made no sense to me.

What DOES work, is the following. However I've no idea how to style the "okButton" (width, colors etc). If that is possible please let me know as it might be simpler.

    myAlert = alert {
      okButton {
         it.dismiss()
         requestLocationPermission()
      }
      customView {
         verticalLayout {
           ..image, textView etc. r here..
           ..
      }
    }
    myAlert.isCancelable = false
    myAlert.show()
ajonno commented 6 years ago

no takers ? i still can't figure this out!

jlberrocal commented 6 years ago

This project is seems to be abandoned by JetBrains