anko icon indicating copy to clipboard operation
anko copied to clipboard

Can't use a normal editText in a dialog

Open blastrock opened this issue 6 years ago • 2 comments

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.

blastrock avatar Feb 03 '19 12:02 blastrock

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 avatar Feb 03 '19 14:02 blastrock

@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.

vyi avatar Oct 03 '19 21:10 vyi