Select all text inside EditText when it gets focus

android, android-edittext

Solution

You can try in your `main.xml` file:

android:selectAllOnFocus="true"

Or, in Java, use

editText.setSelectAllOnFocus(true);

Problem

I have an EditText with some dummy text in it. When the user clicks on it I want it to be selected so that when the user starts typing the dummy text gets deleted. How can I achieve this?

Original source

Related problems