Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I Mask A Password With Anko?

Tags:

kotlin

anko

I realize Anko (and Kotlin) are both pretty cutting edge but I was hoping someone might be able to give me a little guidance on this. This is just a learning project for me, of course.

I've got the following Kotlin code (using Anko) only 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}!")
        }
    }
}

Everything's building and displaying but I can't seem to get the password editText to mask the input as I'm typing it in. What am I missing?

like image 834
Onorio Catenacci Avatar asked May 01 '15 20:05

Onorio Catenacci


2 Answers

The right way is:

editText {
    inputType = TYPE_CLASS_TEXT or TYPE_TEXT_VARIATION_PASSWORD
}
like image 77
yanex Avatar answered Oct 15 '22 09:10

yanex


Actually you have to Reference it from InputType like this:

editText { 
    inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD
}
like image 3
Eefret Avatar answered Oct 15 '22 08:10

Eefret