EditText editText = findViewById(R.id.editText); int textLength = editText.getText().length(); editText.setSelection(textLength);
EditText editText = findViewById(R.id.editText); editText.setText("This is some sample text."); editText.setSelection(5, 10);In this example, the text "is so" will be highlighted in the EditText widget. Package Library: android.widget.