Android Kotlin Anko Alert CustomView Errors

187 views Asked by At

Can't seem to find any resources on how to properly create an alert with a customview that has an edittext and perform an action on positiveButton clicked.

fun ForgotPassword() {
    alert {
        title = R.string.signin_reset_password.toString()
        customView { verticalLayout{
            val input = editText {
                hint = "Enter your email"
            }
            positiveButton(R.string.sign_in_reset) {
                mAuth.sendPasswordResetEmail(input.text.toString())
                    .addOnSuccessListener {
                        toast("Reset email has been sent.").show()
                    }
                    .addOnFailureListener{
                        toast("Reset email was not sent. Try again.").show()
                    }
            }
        } }

    }
}

Error 1:

D:\Android\Keep\keep-android\app\src\main\java\com\irondigitalmedia\keep\SignIn.kt: (63, 29): Overload resolution ambiguity:
public inline fun ViewManager.editText(init: (@AnkoViewDslMarker EditText).() -> Unit): EditText defined in org.jetbrains.anko
public inline fun ViewManager.editText(init: (@AnkoViewDslMarker EditText).() -> Unit): EditText defined in org.jetbrains.anko

Error 2:

D:\Android\Keep\keep-android\app\src\main\java\com\irondigitalmedia\keep\SignIn.kt: (64, 21): Unresolved reference: hint
1

There are 1 answers

0
Duane On

I suspect it is related to the fact that the ambiguous signatures in "Error 1" are identical.

Could there be two versions of Anko in your dependencies somehow?

I suspect "Error 2" will go away when "Error 1" is resolved.