You can create a Map
to store all the EditText
objects that have TextWatcher
's
For example
Map<EditText, Boolean> textWatcherMap = new HashMap<>();
When you add the TextWatcher
to the EditText
, add its reference to the HashMap
.
TextWatcher textWatcher = new TextWatcher(..);
EditText editText = (EditText) findViewById(R.id.editTextId);
editText.addTextChangedListener(textWatcher);
textWatcherMap.put(editText, true);
Then when you are working on the EditText
, check the HashMap
for the reference
if(textWatcherMap.get(editText) != null)
useCurrentTextWatcher();
else
{
addNewTextWatcher();
textWatcherMap.put(editText, true);
}