Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Remove text onfocus of EditText in android?

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?

like image 712
UMAR-MOBITSOLUTIONS Avatar asked Feb 24 '10 14:02

UMAR-MOBITSOLUTIONS


2 Answers

android:hint="username"

put this attribute in EditText

thats it.

like image 187
Praveen Avatar answered Oct 09 '22 18:10

Praveen


onclickListener does not work with EditText items, you'll have to use an OnFocusListener.

like image 36
Frig Avatar answered Oct 09 '22 18:10

Frig