I have multiple edit texts in activity and using textwatcher to take/observe user input. Using methods for each editexts for writing functionality. sometimes i had to use same method for multiple edittexts where it is causing the java.lang.StackOverflowError: stack size 8MB error.Kindly someone help me or anyone suggest me how to use same method for multiple edittext watchers. it will be helpful.
Asked
Active
Viewed 404 times
-3
-
Check if the method is recursing into an endless loop calling itself. – Venkata Narayana Apr 17 '19 at 10:25
-
do not change text from textwatcher (when other textwatcher is observe it) or add guard which would be doing only once (like `boolean wasCalledFromTextWatcher;` then in textwatcher `if(!wasCalledFromTextWatcher) { wasCalledFromTextWatcher = true; /*logic*/ wasCalledFromTextWatcher = false;}`) – Selvin Apr 17 '19 at 10:25
-
tq @Selvin i found the error. – john Doe Apr 17 '19 at 10:31
1 Answers
1
The TextWatcher might be getting called endlessly.
For instance, the text watcher of the first EditText changes text of the other EditText which causes the TextWatcher to get triggered again which triggers another call to the TextWatcher and this process continues indefinitely until the Stack is full.

Venkata Narayana
- 1,657
- 12
- 25