android - TextInputLayout EditText nextFocusRight 不能正常工作

标签 android android-edittext android-textinputlayout

我有两个并排的 TextInputLayout 元素:名字和姓氏。在它们下面我有另一个全宽 TextInputLayout 元素:电子邮件。

我正在尝试覆盖键盘上的下一步按钮,以便在名字输入中单击下一步时,它应该转到姓氏输入,然后从那里转到电子邮件等。

现在的问题是,当我在键盘上按“下一步”时,它不会转到姓氏字段,而是转到它下面的电子邮件。

这是我的 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 是否可以实现下一个焦点,或者它是一个错误还是我只是做错了什么?

最佳答案

改成这个 --> android:nextFocusDown="@+id/register_input_lastname"

关于android - TextInputLayout EditText nextFocusRight 不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34902806/

相关文章:

android - Eclipse:Android 项目中 JDK 类的 java.lang.NoClassDefFoundError

android - GAServiceManager 类型的 setLocalDispatchPeriod(int) 方法已弃用

java - 在 android graphview 中添加背景图像

android - 如何在 android 中使用多个 imeOptions

android - 使用 ExposeDdropDownMenu 样式时如何更改 TextInputLayout Material 下拉箭头可绘制

android-layout - 在合并布局根标签的自定义 View 中应用样式

android - 在 RTL 中格式化时,TextView 中的数字会反转

android - EditText 内的水平文本滚动

java - 如何在android中捏缩放编辑文本?

android - 更改密码向左切换重力(对于 RTL 语言)