I make a chat. In it you can answer the person and in the EditText at the beginning inserts the type of Ваня, - appeal. How can you make this appeal indelible?
|
1 answer
Try this option
editText.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) { EditText edit = (EditText) getCurrentFocus(); if (edit != null) { if (!s.toString().startsWith("Ваня,")) { edit.setText("Ваня,"); Selection.setSelection(edit.getText(), edit.getText().length()); } } } }); |