开发者

Display a message inside Android Edit Text Field

开发者 https://www.devze.com 2023-01-08 19:14 出处:网络
Hai, I have an Android Program with one text field. I need to display a message inside that textfield when it loads on an emulator.

Hai, I have an Android Program with one text field. I need to display a message inside that textfield when it loads on an emulator. When the user clicks inside that textbox that message should dispappear. For Ex: Please enter 开发者_如何学Goname Can any one post some sample code over here...


Just use or call setHint on the object. Hint text to display when the text is empty.

<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18px"
        android:gravity="left"
        android:hint="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse egestas ullamcorper facilisis." />


You need to use the attribute Hint of the EditText.

android:hint in your xml
setHint(int) at runtime

This will execute just what you need

0

精彩评论

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