For some reason, the method addTextChangedListener
is not called for me.
However the method doBeforeTextChanged
, doOnTextChanged
and doAfterTextChanged
worked perfectly :
amountTextField.doBeforeTextChanged { text, start, count, after ->
Log.d(TAG, "beforeTextChange.") // OK, called
}
amountTextField.doOnTextChanged { text, start, before, count ->
Log.d(TAG, "onTextChanged.") // OK, called
}
amountTextField.doAfterTextChanged {
Log.d(TAG, "afterTextChanged.") // OK, called
}
amountTextField.addTextChangedListener {
object: TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
Log.d(TAG, "beforeTextChange.") // NOK, not called
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
Log.d(TAG, "onTextChanged.") // NOK, not called
}
override fun afterTextChanged(p0: Editable?) {
Log.d(TAG, "onTextChanged.") // NOK, not called
}
} }
By the way, the result was always the same : whether I set any text to my EidtText or not, whether after or before I set any text.