Reputation: 91750
I'm looking to build a simple input form for username/password, and I was wondering if it was possible to mimic the functionality that many websites offer, namely a temporary string within a text input displaying what the field's purpose is. Essentially, I need something like this:
When the user hasn't yet focused in on the text input, it should display "USERNAME" in a different format. When the user has focused in on the text field, the field is cleared and focus is set and the style is changed. Is there a way to do this easily?
Upvotes: 4
Views: 4643
Reputation: 1237
You can simply set android:hint="USERNAME" in a particular edittext.
When you will write something in that edittext, it will clear the hint and set your text.Simple...
Upvotes: 2
Reputation: 7350
look at the properties of the edittext - there is a "hint" property that does just that.
android:hint="Enter Username"
Upvotes: 5