开发者

how to Remove text onfocus of EditText in android?

I have a scenario, for example, a EditText in acitivity instead 开发者_如何学Goof 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?


android:hint="username"

put this attribute in EditText

thats it.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜