when I tested adding two TextWatchers to one EditText, it seems like first TextWatcher that is registered gets ignored and only TextWatcher that is registered last works fine. for example,
myEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(...) {}
override fun onTextChanged(...) {}
override fun afterTextChanged(s: Editable) { // first logic here}
})
then I add one more TextWatcher to myEditText
myEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(...) {}
override fun onTextChanged(...) {}
override fun afterTextChanged(s: Editable) { // second logic here}
})
now first logic gets ignored and only second logic remains and works.
I wonder if there is a way to make both of them work together.
(if someone who has experience of hbb20 ccp library, could you also take a look at this thread and get me some help as well?)
I appreciate your help in advanced.
Edit:
my real problem was at logic1 and logic2 not on two TextWatchers. logic1 and logic2 were trying to update one same variable with two different conditions. my code was something like this(which was the problem).
button1.isEnable = s.toString().length == 2 // in first TextWatcher
button1.isEnable = s.toString().length == 3 // in second TextWatcher
so actually second TextWatcher's condition was overriding first TextWatcher's condition.
Conclusion: multiple TextWatchers on single EditText will work just fine
my questions was wrong since my logic was wrong. but thanks to all who tried to help me!
Now you can use multiple TextWatcher such as below :