I have an android xml layout and i want to specify the focus order of the fields, when user presses next on the keyboard.
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!
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.