开发者

Android text input - field name shown in field itself

开发者 https://www.devze.com 2023-03-20 10:25 出处:网络
I am trying to achieve a log-in screen like the following: Where the field\'s name is displayed in the field itself. I am using 开发者_如何学Gothe ADT plugin in Eclipse. I tried setting the android:t

I am trying to achieve a log-in screen like the following:

Android text input - field name shown in field itself

Where the field's name is displayed in the field itself. I am using 开发者_如何学Gothe 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>


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


Share Java code for when click on Submit Button then Show the Name

<EditText
        android:id="@+id/name_enter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/Name"
        android:inputType="textCapSentences|textAutoCorrect"
        />
0

精彩评论

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