Android keyboard next button issue on EditText

AndroidAndroid Edittext

Android Problem Overview


I am facing an issue, I have username & password fields on activity, now when I click on username keyboard appears but no next button on it and I cannot move to next Edittext control through keyboard in this case, keyboard displays enter button in it as attached in screenshot which increases its height,

Can anyone guide me what is the solution to this problem (to display next button on edittext)?

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);

Android Solutions


Solution 1 - Android

Add android:singleLine="true" android:nextFocusDown="@+id/textView2" on your xml. Will show Next key and also focus to the next field.

Solution 2 - Android

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

More Examples

Solution 3 - Android

add this lines below your lines of code you provided:

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

Solution 4 - Android

If your EditText is supposed to have only 1 line, add the attribute android:singleLine="true" on your XML, that will remove the Enter key and replace it with Next / Done button.

Solution 5 - Android

Another best solution would be:

android:singleLine="true" 
android:imeOptions="actionNext"

Solution 6 - Android

add your xml layout ,

in suppose u want 4 edittext in row so first three editext u set below,

android:imeOptions="actionNext"

and last one editext u set

android:imeOptions="actionDone"

u add line so add,Use

  android:singleLine="true" 

Solution 7 - Android

You need to take care of few things:

  1. Add android:singleLine="true".
  2. Add android:nextFocusDown="@+id/tv2" on your XML.
  3. Don't add android:imeOptions="actionNext", otherwise it will override above two attributes.

Solution 8 - Android

use this attribute:

android:inputType="textPersonName"

Solution 9 - Android

Add

android:inputType="text"

line in your edittext tag. and your problem will be resolved.

Solution 10 - Android

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

Solution 11 - Android

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

Solution 12 - Android

android:singleLine="true" is deprecated

use

 android:maxLines="1"
 android:inputType="text"

instead

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionUMAR-MOBITSOLUTIONSView Question on Stackoverflow
Solution 1 - AndroidnijasView Answer on Stackoverflow
Solution 2 - Androiddeepak SharmaView Answer on Stackoverflow
Solution 3 - AndroidHiral VadodariaView Answer on Stackoverflow
Solution 4 - AndroidSERPROView Answer on Stackoverflow
Solution 5 - AndroidHarsh MittalView Answer on Stackoverflow
Solution 6 - AndroidKunal DharaiyaView Answer on Stackoverflow
Solution 7 - AndroidShivam YadavView Answer on Stackoverflow
Solution 8 - AndroidbeboshView Answer on Stackoverflow
Solution 9 - Androidmehmoodnisar125View Answer on Stackoverflow
Solution 10 - Androidsumit pandeyView Answer on Stackoverflow
Solution 11 - AndroidArpit PatelView Answer on Stackoverflow
Solution 12 - AndroidManoharView Answer on Stackoverflow