Android - 单个 TableRow 中的多个 EditText

标签 android android-edittext tablerow

我在一个 TableLayout>TableRow 中有两个 EditText 控件。我有另一个具有单个 EditText 控件的 TableLayout>TableRow。当我从第一个 EditText 字段中点击“Enter”或“Next”时,焦点转到下一个表/行,而不是同一个 TableRow 中的 EditText 字段。我已经搜索过,但没有找到答案。如何使焦点转到下一个 EditText 字段,而不是下一个表格中的 EditText 字段?

            <TableLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_height="wrap_content" 
            android:layout_marginBottom="10dp" 
            android:layout_width="fill_parent">

              <TableRow 
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

                    <TextView 
                        xmlns:android="http://schemas.android.com/apk/res/android"
                        android:text="State" 
                        android:layout_width="wrap_content" 
                        android:layout_height="wrap_content" 
                        android:layout_marginTop="2sp" 
                        android:layout_marginRight="47dp" 
                        android:padding="3dp" 
                        android:textColor="@color/white" 
                        android:textStyle="normal" 
                        android:textSize="12dp">
                    </TextView>

                    <EditText 
                        android:layout_height="30sp" 
                        android:id="@+id/addeditServeeDetail_StateTextBox" 
                        android:layout_width="50dp" 
                        android:singleLine="true"
                        android:textSize="10sp" 
                        android:maxLength="2" android:imeOptions="actionNext">
                    </EditText>

                    <TextView 
                        xmlns:android="http://schemas.android.com/apk/res/android"
                        android:text="Zip" 
                        android:layout_width="wrap_content" 
                        android:layout_height="wrap_content" 
                        android:layout_marginTop="2sp" 
                        android:layout_marginRight="5dp"
                        android:layout_marginLeft="20dp"  
                        android:padding="3dp" 
                        android:textColor="@color/white" 
                        android:textStyle="normal" 
                        android:textSize="12dp">
                    </TextView>

                    <EditText 
                        android:layout_height="30sp" 
                        android:id="@+id/addeditServeeDetail_ZipTextBox" 
                        android:layout_width="100dp"
                        android:singleLine="true"
                        android:textSize="10sp" 
                        android:maxLength="10">
                    </EditText>

            </TableRow>

        </TableLayout>

        <TableLayout
            android:orientation="vertical"
            android:layout_height="wrap_content" 
            android:layout_marginBottom="10dp" 
            android:layout_width="fill_parent">

              <TableRow 
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="2dp"
                android:paddingTop="3dp">

                <TextView 
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:text="County" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" 
                    android:layout_marginTop="2sp" 
                    android:layout_marginRight="35dp" 
                    android:padding="3dp" 
                    android:textColor="@color/white" 
                    android:textStyle="normal" 
                    android:textSize="12dp">
                </TextView>

                <EditText 
                    android:layout_height="30sp" 
                    android:id="@+id/addeditServeeDetail_CountyTextBox" 
                    android:layout_width="200dp"
                    android:singleLine="true" 
                    android:textSize="10sp">
                </EditText>

            </TableRow>

        </TableLayout>

最佳答案

如果您需要焦点以精确的顺​​序从一个项目移动到另一个项目,您需要在布局文件中指定它。

看这个:http://developer.android.com/guide/topics/ui/ui-events.html#HandlingFocus

android:nextFocusDown="@+id/YourNextEditText"

关于Android - 单个 TableRow 中的多个 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7521341/

相关文章:

java - 如何通知跨度已更改的 EditText,而无需重新读取整个字符串

java - 当最小值可以是 android 中的有符号数字时,如何修复编辑文本的最小值?

android - 动态添加 XML 布局到 TableRow Android

android - 无法使用带有口味和com.google.gms.google-services插件的Gradle构建应用

android - 如何从 SimpleCursorAdapter 获取信息到 ContextMenu

android - 如何将 ISO4217 货币代码提供给 NumberFormat?

android - 如何从 Android TextView 中的自动链接中排除某些数字

java - 如何在 EditText 中插入文本?

jQuery 循环遍历 TableRows/Table Cells 性能

c# - 如何从 WPF 中 FlowDocument 的表中的 TableRow 获取 TableCell 值?