Android EditText background text

2019-02-04 09:04发布

问题:

Is there a way to set the background text of an EditText? for instance, I have a login screen with 2 EditText views, one for username and one for password. I want the text "Username" and "Password" be written inside the EditText, and once the user touches those the text disappears but once user deleted his own entry, text re-appears.

Is there a property for that or should I implement this on my own with events and stuff?

回答1:

The hint property will take care of that for you.



回答2:

Use hint property, or setHint method.