Android Studio TextWatcher attributes names issue

151 Views Asked by At

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.

1

There are 1 best solutions below

3
Mohammad Derakhshan On

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.