anko
anko copied to clipboard
Can't use a normal editText in a dialog
Hi,
I am trying to show a dialog with an EditText inside, here's my code, inspired by your wiki:
alert("blah blah") {
customView { editText() }
positiveButton(android.R.string.ok) {}
negativeButton(android.R.string.cancel) {}
}.show()
However, editText doesn't work this way, it takes an InputConstraints as first argument. InputConstraints is an enum on which the only value is PASSWORD. I just want a normal text, what should I do?
I am using
implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
with anko 0.10.8.
I think I found the reason: the wrong editText()
was called because the wrong customView
was used.
customView
can't be called like that because it refers to the customView
property, and not the extension function, this gives the following errors:
Using 'getter for customView: View' is an error. Property does not have a getter
Expression 'customView' of type 'View' cannot be invoked as a function. The function 'invoke()' is not found
Here is a workaround that avoids calling the extension function:
customView = ctx.UI {
editText()
}.view
@blastrock I used your workaround. Thanks.
This error still exists in 0.10.8 Its so frustrating when wiki examples don't run.
I hope this error receives attention of the developers and gets resolved.