Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created August 13, 2024 10:38
Show Gist options
  • Save anitaa1990/346e0352e31a692dad54232d6e633756 to your computer and use it in GitHub Desktop.
Save anitaa1990/346e0352e31a692dad54232d6e633756 to your computer and use it in GitHub Desktop.
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
editText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
// Empty implementation
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// In most scenarios, this is the only method we use. The other methods are often unnecessary in these cases.
}
override fun afterTextChanged(s: Editable?) {
// Empty implementation
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment