我正在构建这个应用程序,我希望用户使用软键盘的下一步按钮来改变EditTexts的焦点,就像图片一样,但它只是将我使用的第一列的焦点一直向下移动
android:nextFocussForward
使用所需的id EditText,但它不起作用(nextfoucusleft/right/up/down不起作用)
它包含一个父级垂直线性布局每行都是水平线性布局
下面是XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/header"
>
<TextView
android:text="@string/ecrit"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="@dimen/text_size_label"
android:textAlignment="center"/>
<TextView
android:text="@string/orale"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1" />
<TextView
android:text="@string/lecture"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cells"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/ecrit1"
android:inputType="number"
android:maxLength="3"
/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/orale1"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/lecture1"
android:inputType="number"
android:maxLength="3"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cells"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/ecrit2"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/orale2"
android:inputType="number"
android:maxLength="3"
/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/lecture2"
android:inputType="number"
android:maxLength="3"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cells"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/ecrit3"
android:inputType="number"
android:maxLength="3"
android:nextFocusRight="@id/orale1"
android:nextFocusForward="@id/orale1"
android:nextFocusDown="@id/orale1"
android:nextFocusUp="@id/orale1"
android:nextFocusLeft="@id/orale1"
/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/orale3"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/lecture3"
android:inputType="number"
android:maxLength="3"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/result"
>
<TextView
android:paddingLeft="8dp"
android:text="@string/zero"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="@dimen/text_size_label"
android:textAlignment="center"/>
<TextView
android:paddingLeft="8dp"
android:text="@string/zero"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1" />
<TextView
android:paddingLeft="8dp"
android:text="@string/zero"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:background="@color/header"
>
<TextView
android:text="@string/examen_ecrit"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="@dimen/text_size_label"
android:textAlignment="center"/>
<TextView
android:text="@string/examen_orale"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1" />
<TextView
android:text="@string/examen_finale"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:textSize="@dimen/text_size_label"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cells"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/ecritFinal"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/oraleFinal"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/finaleFinal"
android:inputType="number"
android:maxLength="3"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@color/header"
android:text="@string/classactivity"
android:textSize="@dimen/text_size_label"/>
<TextView
android:textSize="@dimen/text_size_label"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@color/result"
android:text="@string/zero"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@color/header"
android:text="@string/finalgrade"
android:textSize="@dimen/text_size_label"/>
<TextView
android:textSize="@dimen/text_size_label"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@color/result"
android:text="@string/zero"/>
</LinearLayout>
</LinearLayout>
发布于 2016-09-03 12:45:00
尝试使用android:imeAction = "actionNext"
和android:nextFocussForward
。
https://stackoverflow.com/questions/39306512
复制