How to monitor the input of EditText?

problem description

now there is a requirement to listen only for content changes caused by keyboard input in EditText, while ignoring text changes caused by setText () .

desired effect:

  1. enter a paragraph of text through the keyboard: the listener is called
  2. call setText ("aaaa") : the listener is not called

and TextWatcher is called in both cases.
is there a correct solution to achieve the above results?

Jul.27,2021

found the solution here.
https://www.jianshu.com/p/e6a.

xxxEdit.removeTextChangedListener(watcher);
xxxEdit.setText("");
xxxEdit.addTextChangedListener(watcher);
Menu