Android add placeholder text to EditText

后端 未结 8 879
感动是毒
感动是毒 2020-12-02 04:34

How can I add a placeholder text to EditText in the class that isn\'t in the XML?

I have the following EditText in my code which will be sh

8条回答
  •  情书的邮戳
    2020-12-02 04:56

    You have to use the android:hint attribute

    
    

    In Android Studio, you can switch from XML -> Design View and click on the Component in the layout, the EditText field in this case. This will show all the applicable attributes for that GUI component. This will be handy when you don't know about all the attributes that are there.

    You would be surprised to see that EditText has more than 140 attributes for customization.

提交回复
热议问题