ImeOptions "actionNext" programmatically - how to go to the next field?

In the XML layout, you can specify android:imeOptions="actionNext" , which adds the Next button to the virtual keyboard and, clicking on it - the focus moves to the next field.

How to do this programmatically - for example, based on any trigger trigger event, to move to the next field?

+81
android android widget
Aug 11 '10 at
source share
6 answers

You can use constants from the EditorInfo class for IME parameters. as,

 editText.setImeOptions(EditorInfo.IME_ACTION_NEXT); 
+167
May 09 '11 at 19:38
source share

Find the following custom field and call requestFocus() .

 TextView nextField = (TextView)currentField.focusSearch(View.FOCUS_RIGHT); nextField.requestFocus(); 
+26
Aug 11 '10 at 14:13
source share

Just a suggestion if you use

  EditTextSample.setImeOptions(EditorInfo.IME_ACTION_DONE); 

this does not work, make sure your EditText uses one line.

For example:

  editTextSample.setSingleLine(); 
+15
Feb 01 '16 at 2:20
source share

There is always a need to add additional keys, except for the default keys available on the QWERTY virtual keyboard.

Using XML

 <EditText android:text="@+id/EditText01" android:id="@+id/EditText01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:imeOptions="actionDone"/> 

By Programmatic Way

An EditorInfo is the most useful class when you have to deal with any type of user input in your Android application.

IME_ACTION_DONE: This action performs the "done" operation to enter nothing, and the IME will be closed.

  EditTextSample.setImeOptions(EditorInfo.IME_ACTION_DONE); 

For more information, you can visit http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html

+8
May 03 '15 at 6:30 a.m.
source share

Kotlin suspension

 editText.imeOptions = EditorInfo.IME_ACTION_DONE 
0
Oct 22 '18 at 14:01
source share
 editText.setLines(1); editText.setSingleLine(true); editText.setImeOptions(EditorInfo.IME_ACTION_GO); 

I solve the problem, make sure in one line and go to the next editText when you press Enter

0
Apr 17 '19 at 22:33
source share



All Articles