DKV
DKV

Reputation: 1767

Moving the focus to the Right side of an EditText when the Next button is clicked

I Need to change the focus to the edite text in the right side. I have alredy given the android:nextFocusRight But. it is not moving to the ridhtside. insted it move the focus to the down side.

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:nextFocusRight="@id/edt2"
            android:inputType="text"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>

Upvotes: 1

Views: 381

Answers (2)

Mithun Halmare
Mithun Halmare

Reputation: 33

You Just have to use property "nextFocusDown" instead of "nextFocusRight" it will solve your Problem

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="text"
            android:nextFocusDown="@id/edt2"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>

Upvotes: 0

AskNilesh
AskNilesh

Reputation: 69689

Try this use android:imeOptions="actionNext" in your edt1 EditText it will work

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:imeOptions="actionNext"
            android:nextFocusRight="@+id/edt2"
            android:inputType="text"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>

Upvotes: 2

Related Questions