How to clear selection in EditText?

How do you programmatically remove selection from an EditText? I tried:

myEditText.setSelection(selectionEnd);

but it just creates a selection of 0 lengths at the end of the current selection. I also tried Selection.removeSelection(mySpannable)and it just puts an empty selection at the beginning of the text.

+5
source share
2 answers

Challenge myEditText.clearFocus();. I think you need

+9
source
EditText message = (EditText) findViewById(R.id.sendText);
String text = message.getText().toString();
message.setText(null);
0
source

All Articles