Next button on Android keyboard on EditText

I ran into a problem: I have username and password fields for activity, now when I click on the username keyboard but don’t click the next button on it and I can’t go to the next Edittext control via the keyboard, in this case the keyboard displays the enter button in it as attached in the screenshot, which increases its height,

will someone tell me what is the solution to this problem (to display the next button on edittext)?

any help would be appreciated enter image description here

My code

txtUserid = (EditText)findViewById(R.id.txtUserID); txtUserPasword = (EditText)findViewById(R.id.txtPassword); txtUserid.setNextFocusDownId(R.id.txtPassword); txtUserPasword.setNextFocusDownId(R.id.btnLogin); 
+46
android
Jan 25 2018-12-12T00:
source share
9 answers

add these lines below your lines of code that you specified:

 txtUserid.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on Enter key press txtUserid.clearFocus(); txtUserPasword.requestFocus(); return true; } return false; } }); txtUserPasword.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on Enter key press // check for username - password correctness here return true; } return false; } }); 
+29
Jan 25 '12 at 13:11
source share
β€” -

Add android:singleLine="true" android:nextFocusDown="@+id/textView2" to your xml. Will display the next key, and go to the next field.

+92
Feb 11 '13 at 9:42
source share

In your layout, just set the XML attributes android:imeOptions="actionNext" for the first three text fields and android:imeOptions="actionDone" for the last.

Additional examples

+47
Jan 25 2018-12-12T00:
source share

If your EditText should have only one line, add android:singleLine="true" to your XML attribute, which will remove the Enter key and replace it with the Next / Done button.

+5
Jan 25 '12 at 13:20
source share

use this attribute:

 android:inputType="textPersonName" 
+2
Nov 24 '14 at 8:13
source share

Another best solution:

 android:singleLine="true" android:imeOptions="next" 
+2
Jun 29 '16 at 17:00
source share

Just add android: singleLine = "true" to the EditText tag in the XML layout ..

+1
Jul 27 '12 at 8:33
source share

Just add android: singleLine = "true" you don't need this code for

+1
Aug 01 '15 at 5:15
source share

add your xml layout

suppose u wants 4 edittext per line, so the first three editext u are set below,

 android:imeOptions="actionNext" 

and the last one editext u set

 android:imeOptions="actionDone" 

u add line so add use

  android:singleLine="true" 
+1
Mar 20 '17 at 13:13
source share



All Articles