Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Softkeyboard "Enter" button Text in android?

I want to set the softkeyboard to "Enter" key text to "Done". Is there any way to change the text of the enter key of the softkeyboard of the android device? Please suggest if anyone have any idea.

Thank you in advance.

like image 436
GrIsHu Avatar asked Dec 31 '12 10:12

GrIsHu


People also ask

How do I change the Done button on my android keyboard?

First you need to set the android:imeOptions attribute equal to actionDone for your target EditText as seen below. That will change your 'RETURN' button in your EditText's soft keyboard to a 'DONE' button. android:singleLine is deprecated. Use android:maxLines="1".

How do you press Enter on android keyboard?

press the shift key and see the change in the icon for the smiley. It changes to the enter key.


2 Answers

In XML for the editText put

android:imeOptions="actionDone"
like image 155
Faizan Avatar answered Sep 29 '22 13:09

Faizan


    Apply inputType and imeOptions tag in EditText. Here inputType property is the type of data to be inserted and imeOptions is the action. this action may be go to next edittext, search, enter etc. This property change the icon on bottom right corner of the soft keyboard.



 <EditText
            android:id="@+id/username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:hint="user name" />

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="password"
            android:inputType="numberPassword"
            android:imeOptions="actionSearch"/>

Java Code

  EditText userName = findViewById(R.id.username);
                EditText password = findViewById(R.id.password);

// Set the action listener on editText

            userName.setOnEditorActionListener(editorActionListener);
            password.setOnEditorActionListener(editorActionListener);
        }

 // and based on the emeOptions define in EditText add listeners when the 
 //enter key key pressed in softKeyboad 

        private TextView.OnEditorActionListener editorActionListener = new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                switch (actionId){
                     case EditorInfo.IME_ACTION_NEXT:
                        Toast.makeText(MainActivity.this, "Next", Toast.LENGTH_SHORT).show();
                        break;

                    case EditorInfo.IME_ACTION_SEARCH:
                        Toast.makeText(MainActivity.this, "SEARCH", Toast.LENGTH_SHORT).show();
                        break;
                }
                return false;
            }
        };
like image 42
Rajneesh Shukla Avatar answered Sep 29 '22 13:09

Rajneesh Shukla