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?
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?
Managed it by calling focus and selection on program
I tried an above answer and didn't work until I switched the statements. This is what worked for me:
I had to ask if the focus is on the EditText, and if not request the focus first and then clear it. Otherwise the next times I clicked on the EditText the virtual keyboard would never appear
You can also add an OnClick Method to the editText after
and in that:
As soon as you click the editText the whole text is selected.
Why don't you try android:hint="hint" to provide the hint to the user..!!
The "hint" will automatically disappear when the user clicks on the edittextbox. its the proper and best solution.
You can try in your
main.xml
file:This works if you want to do it programatically.