我在一个 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/