8

How do I put text into empty TextView so it goes away when user starts typing? Just like here in StackOverflow under "Tags" field.

Same approach used in GMail client. That will save me some space - no need to create labels..

katit
  • 17,375
  • 35
  • 128
  • 256

2 Answers2

14

Throw an android:hint="hint text" into your EditText xml tag.

Haphazard
  • 10,900
  • 6
  • 43
  • 55
6

As haphazard said or programatically you can use...

setHint(CharSequence hint) or setHint(int resId).

The equivalent to the resource id in xml would be android:hint="@string/hint_text" (for example).

Squonk
  • 48,735
  • 19
  • 103
  • 135