I have a EditText
and when I use:
editText.requestFocus();
I would like you to select the whole text, is it possible?
I have a EditText
and when I use:
editText.requestFocus();
I would like you to select the whole text, is it possible?
There are two ways, the first is to change the ownership of EditText
in the xml layout and add:
android:selectAllOnFocus="true"
The other is via script, in onCreate
you set to select everything in focus:
editText.setSelectAllOnFocus(true);
Then you can use:
editText.requestFocus();
I was not able to test, but I think selectAll
also works:
editText.selectAll();