TextInputLayout EditText nextFocusRight not working as it should

I have two TextInputLayout elements: first and last name. At the bottom, I have another TextInputLayout width element: email.

I am trying to overwrite the next button on the keyboard so that when I click Next inside the firstname input, it should go on to enter the name and from there to email, etc.

Now the problem is that when I click Next on the keyboard, it does not go to the lastname field, but instead is sent to the e-mail below.

This is the part of my xml file where I have three inputs:

 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center_horizontal" android:baselineAligned="false"> <android.support.design.widget.TextInputLayout android:id="@+id/input_layout_firstname" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> <EditText android:id="@+id/register_input_firstname" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_firstname" android:inputType="textCapSentences" android:nextFocusForward="@+id/register_input_lastname" android:nextFocusRight="@+id/register_input_lastname" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/input_layout_lastname" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> <EditText android:id="@+id/register_input_lastname" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_lastname" android:inputType="textCapSentences" android:nextFocusDown="@+id/register_input_email" /> </android.support.design.widget.TextInputLayout> </LinearLayout> <android.support.design.widget.TextInputLayout android:id="@+id/input_layout_email" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/register_input_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_email" android:inputType="textEmailAddress" /> </android.support.design.widget.TextInputLayout> 

I also tried TextInputLayout instead of EditText , but it has no effect.

Is the next trick even possible with TextInputLayout , or is it a mistake, or am I just doing something very wrong?

+5
source share
3 answers

Change this to β†’ android: nextFocusDown = "@ + id / register_input_lastname"

+6
source

The above answer is correct, but I just need to add something, when I try, I don't get focus on the next line, so I add another attribute in addition to the answer above

android: inputType = "your input type is here"

after I put this, I got my focus on text editing the next.

Example

android: inputType = "text" // set any type of input according to your requirement

Android: nextFocusDown = "@ + identifier / next _id"

Full edittext example

 <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" android:textColorHint="@color/hint"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:maxLines="1" android:id="@id/first_name_edt" android:nextFocusDown="@+id/last_name_edt" android:imeOptions="actionNext" android:inputType="text" android:hint="@string/str_first_name" /> </android.support.design.widget.TextInputLayout> 

Hope this helps others :)

+3
source

I used this code under it, working like magic :)

Actually trick

Android: imeOptions = "actionNext"

Android: nextFocusDown = "@ + id / tilAddress"

Android: inputType = "text"

 <android.support.design.widget.TextInputLayout android:id="@+id/tilSchoolName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_small"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="@dimen/text_size_small" android:textColor="@color/colorTxt" android:maxLines="1" android:imeOptions="actionNext" android:nextFocusDown="@+id/tilAddress" android:inputType="text" android:hint="School Name" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/tilAddress" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="@dimen/text_size_small" android:textColor="@color/colorTxt" android:maxLines="1" android:hint="Address" /> </android.support.design.widget.TextInputLayout> 
+1
source

Source: https://habr.com/ru/post/1241030/


All Articles