12

Im using

android:digits="abcdefghijklmnopqrstuvwxyz. " 

and having one more EditText in the same screen when i press enter key in keypad the focus doesn't gets changed.

suppose if i remove the

 android:digits

the enter button works fine and moves to the next edit text.

Jitesh Dalsaniya
  • 1,837
  • 2
  • 19
  • 35

3 Answers3

8

Add android:imeOptions="actionNext" in your EditText in xml

<EditText
        android:id="@+id/et_count"
        android:layout_width="100dp"
        android:singleLine="true"
        android:imeOptions="actionNext"
        android:layout_height="wrap_content" />
Jitender Dev
  • 7,149
  • 2
  • 22
  • 35
  • 2
    not working here. When digits attribute is there, imeOptions doesn't work. why is that ? – Bugs Happen Mar 02 '15 at 08:26
  • 12
    @BugsHappen For a fix try adding android:singleLine="true", reffered from http://stackoverflow.com/questions/11048007/using-androiddigits-attribute-to-restrict-characters-stops-action-next-button-w – Jitender Dev Mar 02 '15 at 10:43
  • please add the singleLine true to answer not just in comments. It fixed the issue with digits . – jace Feb 12 '18 at 03:47
  • 1
    I can confirm `android:singleLine="true"` fixes it in 2018. `android:imeOptions="actionNext"` does not. – Someone Somewhere Mar 05 '18 at 19:14
2

You can make use of the imeOptions attribute available for EditText in xml.

Try the following. It worked in my case.

In XML:

 <EditText
      android:id="@+id/edit_text1"
      android:layout_width="match_parent"
      android:layout_height="45dp"
      android:digits="abcdefghijklmnopqrstuvwxyz. " 
      android:imeOptions="actionNext"/>

<EditText
      android:id="@+id/edit_text2"
      android:layout_width="match_parent"
      android:layout_height="45dp"/>

Then, in JAVA:

    EditText edit_text1 = (EditText) findViewById (R.id.edit_text1);

    EditText edit_text2 = (EditText) findViewById (R.id.edit_text2);

    edit_text1.setOnEditorActionListener(new OnEditorActionListener() {     
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;

            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                edit_text2.requestFocus();
                handled = true;
            }

            return handled;
       }
   });
Hariharan
  • 28,002
  • 7
  • 50
  • 55
0

you must be delete 'android:digits' to active the 'android:imeOptions="actionNext"' code.