android:nextFocusForward是错误的EditText

我正在开发一个 android项目,我正在使用android:nextFocusButton,因此用户可以按下软键盘上的下一个按钮来移动EditText,而无需点击每个编辑文本来更改焦点.

在布局中,我要求用户的名字和姓氏,在水平线性布局中的单独EditText中

然后在下一行,在另一个线性布局中,然后我要求公司名称.下面是截图,显示我的意思.

我要做的是,在第一个名称编辑文本,用户可以按下一个,然后应该将焦点切换到姓氏编辑文本,然后再按下一步,它将移动到公司编辑文本.

相反,正在发生的事情是,第一个名称有焦点,用户按下下一个按钮,然后它转到公司编辑文本而不是姓氏.

下面是我的XML布局的片段

<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <EditText android:id="@+id/createAccount_txtFirstName"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:hint="@string/first_name"
                    android:singleLine="true"
                    android:inputType="textCapSentences"
                    android:nextFocusForward="@+id/createAccount_txtLastName"/>
                <EditText android:id="@+id/createAccount_txtLastName"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:hint="@string/last_name"
                    android:singleLine="true"
                    android:inputType="textCapSentences"
                    android:nextFocusForward="@+id/createAccount_txtCompanyName"/>
            </LinearLayout>
            <EditText android:id="@+id/createAccount_txtCompanyName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/company_name"
                android:singleLine="true"
                android:inputType="textCapSentences"
                android:nextFocusForward="@+id/createAccount_txtEmail"/>

感谢您的任何帮助,您可以提供.

解决方法

只需将其放在您的第一个edittext中即可.同时用nextFocusDown替换nextFocusForward
<EditText android:id="@+id/createAccount_txtFirstName"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:hint="@string/first_name"
                android:singleLine="true"
                android:inputType="textCapSentences"
                android:nextFocusDown="@+id/createAccount_txtLastName">
 <requestFocus />
</EditText>

在模拟器上运行此代码时似乎有问题.但是,它适用于手机

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...