Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android text input - field name shown in field itself

I am trying to achieve a log-in screen like the following:enter image description here

Where the field's name is displayed in the field itself. I am using the ADT plugin in Eclipse. I tried setting the android:text attribute of the text input, but I don't think this is correct because through the password field, only the dots show (the redacted text), and not the text itself. What is the attribute then. I have looked in the documentation for the EditText widget.

The XML I currently have for the two EditText fields are:

    <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/editText1" android:inputType="textEmailAddress" android:text="@string/username">
    <requestFocus></requestFocus>
</EditText>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/editText2" android:inputType="textPassword" android:text="@string/password" ></EditText>
like image 930
Gus Avatar asked Feb 24 '23 13:02

Gus


1 Answers

You should be able to set default values for the fields with android:hint or android:sethint I think its the first.

android:hint="Please enter your password"

its the first one, thanks to a search on SO. Just for additional info it came up with this.

SO Question about android:hint

like image 129
sealz Avatar answered Mar 06 '23 17:03

sealz