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.
it is just naming!
pay attention to the order of
start,before, andcount. thei,i1, andi2variables represent those in the same order. for example, forbeforeTextChangedthei,i1andi2are:you even can change the
i,i1, andi2with any other names especially,start,count, andafter.