How to automatically add a text at beginning of edittext as soon as user start typing in it.For example I want to automatically append country code as soon as user start typing phone number. I tried-
mNumber.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) {
mNumber.setText("+91"+editable.getText().toString());
}
});
But this doesn't worked and my device hangs as soon as i type in the edittext.