Skip to content

Instantly share code, notes, and snippets.

@TheBotBox
Created June 5, 2020 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheBotBox/2942f7be48246e05fe52e6993eb777d1 to your computer and use it in GitHub Desktop.
Save TheBotBox/2942f7be48246e05fe52e6993eb777d1 to your computer and use it in GitHub Desktop.
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