I have this problem in which I have two variables - 'mobile_input' & 'mobile_input_login'. I also have 2 TextUtils also.
Instead of making two different TextUtils, I want to make one TextUtils. I have searched on the web but there is no relevant question like that.
The code:
mobile_input.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) {
if (TextUtils.isEmpty(s.toString().trim())) {
clear2.setVisibility(View.INVISIBLE);
} else {
clear2.setVisibility(View.VISIBLE);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
mobile_input_login.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) {
if (TextUtils.isEmpty(s.toString().trim())) {
clear4.setVisibility(View.INVISIBLE);
} else {
clear4.setVisibility(View.VISIBLE);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
Thank you for your answer in advance.