2013-10-25 19 views

回答

2

在你的EditText添加android:imeOptions="actionNext"在XML

<EditText 
     android:id="@+id/et_count" 
     android:layout_width="100dp" 
     android:singleLine="true" 
     android:imeOptions="actionNext" 
     android:layout_height="wrap_content" /> 
+0

由于做工精细 –

+2

不在这里工作。当数字属性存在时,imeOptions不起作用。这是为什么 ? –

+7

@BugsHappen对于修复尝试添加android:singleLine =“true”,从http://stackoverflow.com/questions/11048007/using-androiddigits-attribute-to-restrict-characters-stops-action-next-button- w –

2

您可以使用imeOptionsxmlEditText属性可用。

请尝试以下操作。它在我的情况下工作。

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

然后,在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; 
     } 
    });