Created
April 10, 2018 15:21
-
-
Save adrianhall/ed038d1561739a0eefd886180e9d53bb to your computer and use it in GitHub Desktop.
An extension function for implementing a text change watcher on EditText
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) { | |
| this.addTextChangedListener(object: TextWatcher { | |
| override fun afterTextChanged(s: Editable?) { | |
| afterTextChanged.invoke(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