-3

I have putted a EditText in a XML. I want to use this EditText to the user insert his name.

I want that appears in this EditText the text "Insert the Name", but when the user click on it, the text "Insert the Name" disappear, so the user don't need to delete the phrase "Insert the Name".

I want the same "Event name" effect in this image:

enter image description here

What is needed to do in the EditText to get this effect? Thanks!

Rodrigo João Bertotti
  • 5,179
  • 2
  • 23
  • 34

2 Answers2

0

This will be helpful: How to clear the selection in an EditText?

do it programatically by using:

myEditText.clearFocus();

which fills it up with actual text

or xml:

android:hint="text here"

which is unselectable greyed out 'hint' text you want

Community
  • 1
  • 1
mewc
  • 1,253
  • 1
  • 15
  • 24
0

Add hint in your Editext in your xml File

<EditText
    android:id="@+id/etName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Insert Name"/>
Vanraj Ghed
  • 1,261
  • 11
  • 23