I need an EditText with a fixed Suffix. I'm using a TextWatcher to catch the onTextChanged Event, but if I change the Text again by adding my suffix it causes a stackoverflow exception caused by an infinite recursion.
msgtextview.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
//Doing some other stuff
msgtextview.setText("Changed Text") //This cause infinite recursion
}
}
Here's the code.
I assume you're having a stack overflow because when you programmatically add the suffix, it triggers an onTextChanged event.
Have you thought about setting a flag right before you set it programmatically so the next time it's called you can know not to add the suffix?
The alternative is to only add the suffix after the user submits your form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With