There is a certain Edit Text, you need to ask him a condition that if 3 letters are registered, My methov started; and if the field is empty again, then returned to the initial position

  • five
    I think you should: 1) read some entry-level books on programming; 2) try to think over and formulate your questions more carefully - m. vokhm
  • Thank you for your comment, but somehow one sensible programmer told me to learn Java from books is impossible. Time and practice only. And he was right, yes I read 2 books 1) Java complete manual 8th edition 2) Library of Java professionals - elik
  • but even so, brezh has everything and no one can say that I didn’t allow primitive mistakes or basic nonsense)) I learned something else I need to learn) everything is given to comparison) thank you for your comment - elik

1 answer 1

editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.length() == 3){ // здесь вызывыете My method } if (charSequence.length() == 0) { // здесь возвращаетесь в начальное состояние } } @Override public void afterTextChanged(Editable editable) { } }); 
  • Thanks to the first time I saw this listener. And so many listeners, are there any claasification of them? I like to read about them - elik
  • @elik Your intelligent programmer did not tell you, besides the dubious advice not to read books, that there is such official documentation , in which ALL possible classes and interfaces of the Android framework are listed. In particular, the interfaces of the View class , from which the EditText is inherited or the method of the TextView class (from which EditText is also inherited) is addTextChangedListener . - pavlofff
  • 3
    @elik If you have any thoughts about a particular class, but you don’t know how to implement them, you should not start by writing the question, but by studying the documentation for this class and the classes above it in the inheritance hierarchy. There you will fully understand the whole classification. - pavlofff