【发布时间】:2016-04-26 11:05:18
【问题描述】:
我有两个并排的TextInputLayout 元素:名字和姓氏。在它们下方,我还有另一个全宽 TextInputLayout 元素:电子邮件。
我正在尝试覆盖键盘上的下一步按钮,以便在单击名字输入中的下一步时,它应该转到姓氏输入,然后从那里转到电子邮件等。
现在的问题是,当我在键盘上按 Next 时,它不会转到姓氏字段,而是转到其下方的电子邮件。
这是我的 xml 文件的一部分,其中包含以下三个输入:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:baselineAligned="false">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/register_input_firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_firstname"
android:inputType="textCapSentences"
android:nextFocusForward="@+id/register_input_lastname"
android:nextFocusRight="@+id/register_input_lastname" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_lastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/register_input_lastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_lastname"
android:inputType="textCapSentences"
android:nextFocusDown="@+id/register_input_email" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_email"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/register_input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_email"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
我也尝试过定位TextInputLayout 而不是EditText,但没有效果。
TextInputLayout 的下一个焦点是否可能,或者它是一个错误还是我只是做错了什么?
【问题讨论】:
-
如果@Yen Pei Tay 的回答没有解决问题,请尝试关注。 stackoverflow.com/a/41489258/1015678
标签: android android-edittext android-textinputlayout