【问题标题】:Android text input - field name shown in field itselfAndroid 文本输入 - 字段名称显示在字段本身
【发布时间】:2011-10-06 08:49:37
【问题描述】:

我正在尝试实现如下登录屏幕:

字段名称在字段本身中的显示位置。我在 Eclipse 中使用 ADT 插件。我尝试设置文本输入的android:text 属性,但我认为这是不正确的,因为通过密码字段,只显示点(编辑文本),而不是文本本身。那是什么属性。我看过the documentation for the EditText widget

我目前拥有的两个 EditText 字段的 XML 是:

    <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>

【问题讨论】:

  • 您介意发布您拥有的 XML 吗?
  • @harper89,我已经编辑了这个问题。如果还有其他问题,请告诉我。

标签: android-layout


【解决方案1】:

单击提交按钮然后显示名称时共享 Java 代码

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

【讨论】:

    【解决方案2】:

    您应该能够为带有android:hintandroid:sethint 的字段设置默认值,我认为这是第一个。

    android:hint="Please enter your password"
    

    它是第一个,这要归功于对 SO 的搜索。只是为了获得更多信息,它想出了这个。

    SO Question about android:hint

    【讨论】:

      猜你喜欢
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-02
      • 1970-01-01
      • 1970-01-01
      • 2015-06-12
      相关资源
      最近更新 更多