How can I hide the password using Anko?

I understand that Anko (and Kotlin) both cut pretty, but I was hoping that someone could give me a little guidance on this. Of course, for me this is just a training project.

I have the following Kotlin code (using Anko), which is very slightly modified from the sample code:

verticalLayout { padding = dip(30) val name = editText { hint = "Name" textSize = 24f } val password = editText { hint = "Password" textSize = 24f inputType = android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD } button("Login") { textSize = 26f onClick { toast("Good afternoon, ${name.text}!") } } } 

The whole building and display, but I can’t get the editText password to mask the input when I type it. What am I missing?

+5
source share
2 answers

The right way:

 editText { inputType = TYPE_CLASS_TEXT or TYPE_TEXT_VARIATION_PASSWORD } 
+11
source

In fact, you need to reference it from InputType as follows:

 editText { inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD } 
+1
source

All Articles