How to remove all listeners added with addTextChangedListener

前端 未结 11 1584
谎友^
谎友^ 2020-11-27 16:24

I have a ListView where each row has an EditText control. I want to add a TextChangedListener to each row; one that contains extra dat

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 17:11

    As you can see here: CodeSearch of TextView there is no way of removing all listeners. The only way is to provide the watcher you used to register it.

    I do not yet fully understand why there are other listeners already registered. However you can subclass the EditText, override the addTextChangedListener(..) and in it keep a copy of all added references yourself and then delegate to the superclass implementation. You then can also provide an additional method that removes all listeners.

    Get in touch if you need further explanations.

提交回复
热议问题