Input predictable on Android
Whenever a user provides input, there should be no change of context
. Example of changing context include, but are not limited to: automatically submitting data, opening a new screen or moving to another element. Input should have predictable effects.
On Android, be careful when using TextWatcher
methods. Do not trigger a change of context when text changes.
private val textWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
// Ignored
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
// Ignored
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// Do not change context
}
}