How to trigger the TextChanged event of EditText

11 views
Skip to first unread message

ales

unread,
Apr 4, 2016, 12:50:52 AM4/4/16
to macroid
Hi,
what is the best Macroid way to trigger the TextChanged event of EditText?

Thank you for any hint.
Ales

ales

unread,
Apr 4, 2016, 2:14:10 AM4/4/16
to macroid
Currently I do it like this, but It is a "little bit" verbose:

var passwordEdit = slot[EditText]
var activateButton = slot[Button]

passwordEdit
.foreach {
    edit
=>
        edit
.addTextChangedListener(new TextWatcher {
           
override def beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) = {}

           
override def onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) = {
                runUi
{
                   
activateButton <~ enable(charSequence.length > 0)
               
}
           
}

           
override def afterTextChanged(editable: Editable) = {}
       
})
}


Reply all
Reply to author
Forward
0 new messages