Android TextInputLayout编辑文本下一个焦点右键不能正常工作
我有两个Android TextInputLayout编辑文本下一个焦点右键不能正常工作,android,android-edittext,android-textinputlayout,Android,Android Edittext,Android Textinputlayout,我有两个TextInputLayout元素并排:firstname和lastname。在它们下面,我有另一个全宽TextInputLayout元素:email 我试图覆盖键盘上的“下一步”按钮,以便在“名字”输入中单击“下一步”时,它应该转到“姓氏”输入,然后再转到电子邮件等 现在的问题是,当我按下键盘上的“下一步”时,它不会进入lastname字段,而是进入它下面的电子邮件 这是xml文件的一部分,其中包含以下三个输入: 我还尝试将文本输入布局作为目标,而不是编辑文本,但没有效果 下一个焦
TextInputLayout
元素并排:firstname和lastname。在它们下面,我有另一个全宽TextInputLayout
元素:email
我试图覆盖键盘上的“下一步”按钮,以便在“名字”输入中单击“下一步”时,它应该转到“姓氏”输入,然后再转到电子邮件等
现在的问题是,当我按下键盘上的“下一步”时,它不会进入lastname字段,而是进入它下面的电子邮件
这是xml文件的一部分,其中包含以下三个输入:
我还尝试将文本输入布局
作为目标,而不是编辑文本
,但没有效果
下一个焦点是否可能与
TextInputLayout
有关,或者是一个bug,还是我只是做错了什么?更改为-->android:nextFocusDown=“@+id/register\u input\u lastname”上述答案是正确的,但我尝试时只需要添加一些内容,因为我无法将焦点转移到下一行,所以我在上述答案的基础上再添加一个属性
android:inputType=“此处输入您的输入类型”
放了这个之后,我把我的编辑文本焦点转到了下一个
范例
android:inputType=“text”//根据需要设置任何输入类型
android:nextFocusDown=“@+id/next_id”
编辑文本的完整示例
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
android:textColorHint="@color/hint">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:id="@id/first_name_edt"
android:nextFocusDown="@+id/last_name_edt"
android:imeOptions="actionNext"
android:inputType="text"
android:hint="@string/str_first_name" />
</android.support.design.widget.TextInputLayout>
希望这能帮助其他人:)我在下面使用了这段代码,它工作起来很神奇:) 实际上,诀窍是 android:imeOptions=“actionNext” android:nextFocusDown=“@+id/tilAddress” android:inputType=“文本”
哈哈,它真的很管用。我猜这是因为焦点自然向下移动,从技术上讲,lastname输入低于firstname。但我不明白为什么会有nextFocusRight等?这些只在常规的EditText输入上起作用吗?不知道,但值得一试。我没有使用加号,这导致它找不到id。添加加号是个好主意,谢谢。如果@Yen Pei Tay的答案不能解决问题,请尝试下面的方法。
<android.support.design.widget.TextInputLayout
android:id="@+id/tilSchoolName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_small"
android:textColor="@color/colorTxt"
android:maxLines="1"
android:imeOptions="actionNext"
android:nextFocusDown="@+id/tilAddress"
android:inputType="text"
android:hint="School Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/tilAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_small"
android:textColor="@color/colorTxt"
android:maxLines="1"
android:hint="Address" />
</android.support.design.widget.TextInputLayout>