android:nextFocusForward在布局中被忽略 [英] android:nextFocusForward is ignored in layout

查看:154
本文介绍了android:nextFocusForward在布局中被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个android xml布局,我想在用户按下键盘上的next键时指定字段的焦点顺序.

I have an android xml layout and i want to specify the focus order of the fields, when user presses next on the keyboard.

文档说, android:nextFocusForward = TARGET_ID 应该可以解决这个问题.但这在我们所有的测试设备上都被忽略了.一些运行2.3的旧设备和运行4.1的新Nexus设备.

Documentation says, that android:nextFocusForward=TARGET_ID should do that trick. But it is ignored on all our testing devices. Some old devices running 2.3 and new Nexus devices running 4.1.

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:textCursorDrawable="@null"
            android:id="@+id/firstname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="6dp"
            android:layout_marginTop="6dp"
            android:layout_weight="1"
            android:singleLine="true"
            android:background="#00000000"
            android:textColor="#000"
            android:nextFocusForward="@+id/lastname"
            android:padding="2dp"/>

        <EditText
            android:textCursorDrawable="@null"
            android:id="@+id/lastname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="6dp"
            android:layout_marginTop="6dp"
            android:layout_weight="1"
            android:background="#00000000"
            android:singleLine="true"
            android:textColor="#000"
            android:padding="2dp"/>
    </LinearLayout>

我在这里做错了什么???只是想不通.非常感谢!

What am i doing wrong here??? Just can't figure it out. Thanks a lot!

推荐答案

也请尝试nextFocusDown.我不完全了解规则,但似乎行为取决于EditTexts的布局以及光标位置相对于下一个字段的位置.

Try nextFocusDown as well. I don't fully understand the rules, but it seems that the behavior depends on the layout of the EditTexts, and where the cursor position is relative to the next field.

这篇关于android:nextFocusForward在布局中被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆