androidlistenertextwatchertextchanged

How to check if my EditText has a TextChangedListener (TextWatcher)?


I know we can add a TextWatcher to EditTexts using addTextChangedListener and remove it using removeTextChangedListener. But now I want to check if my EditText has any TextWatcher or not.

How can I do that?

I have a grid. It has an adapter. My adapter checks if the type of defined item is EditText add a TextWatcher to it. When method getView is called TextWatcher is added to that EditText. I want to avoid adding extra TextWatchers if one is added.


Solution

  • Well there is work around , you can set tag to your edittext inside getview method using setTag method of View , before doing this check if getTag is not null if so you have already set TextWatcher...

    if(editText object getTag is null then editText.seTtag and add watcher) else return