views:

643

answers:

3

I have a scenario, for example, a EditText in acitivity instead of using Textview as a label of it i want to put text "UserName" inside EditText and if user clicks on it. it should disappear and EditText should get empty to enter data in it.

How can I achieve this?

A: 

Use setOnClickListener() to register a listener that then checks if the EditText just contains "UserName", and clears it out if that is true.

mbaird
+4  A: 

android:hint="username"

put this attribute in EditText

thats it.

Praveen Chandrasekaran
A: 

Thanks praveen! That worked for me !! =)

Sagar Hatekar