android:digits not allowing next button in keypad

让人想犯罪 __ 提交于 2019-12-10 12:36:32

问题


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.


回答1:


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" />



回答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;
       }
   });



回答3:


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



来源:https://stackoverflow.com/questions/19588503/androiddigits-not-allowing-next-button-in-keypad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!