Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun EditText.onTextChanged(listener: (String) -> Unit) {
this.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) { listener(s.toString()) }
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment