0

I'm actually following a class on creating my first android application with Android Studio. I need to use TextWatcher, and obtain something like this :

mNameEditText.addTextChangedListener(new TextWatcher() {
   @Override
   public void beforeTextChanged(CharSequence s, int start, int count, int after) {
       
   }
 
   @Override
   public void onTextChanged(CharSequence s, int start, int before, int count) {
 
   }
 
   @Override
   public void afterTextChanged(Editable s) {
       // This is where we'll check the user input
   }
});

But instead, I'm obtaining this :

mNameEditText.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) {
 
            }
 
            @Override
            public void afterTextChanged(Editable editable) {
 
            }
        });

As you can see, I don't have start, count and after but i, i1 and i2. The class explains that it's an issue, and how to fix it : by downloading the source code of the android version I'm using with the SDK Manager. I've downloaded the version I clicked on when creating my project, but it's not solving my issue.

I really hope someone can help me, thank you for your time.

Barrow
  • 1

1 Answers1

0

it is just naming!

pay attention to the order of start, before, and count. the i, i1, and i2 variables represent those in the same order. for example, for beforeTextChanged the i, i1 and i2 are:

i=>start
i1=>count
i2=>after

you even can change the i,i1, and i2 with any other names especially, start, count, and after.

Mohammad Derakhshan
  • 1,262
  • 11
  • 33
  • Oh ok thank you! Because I saw that for everyone the names were start, before and count by default, and not for me haha, this is okay or is there a manipulation to do to get it right? Thank you very much for your response! – Barrow Aug 02 '21 at 18:17
  • No, it's not a big deal. It is the auto-generated name by the android studio. I suggest you change them to any name that makes sense to you. I'll be glad if you found this answer helpful, vote it up – Mohammad Derakhshan Aug 02 '21 at 18:21
  • alright, thank you very much! I did, have a nice day! – Barrow Aug 02 '21 at 18:46