Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android soft keyboard custom "Done" button text?

Tags:

I'm aware I can set my "done" button to different things using

EditText.setImeOptions();

but how would I set it to custom text? Is it possible for me to specifiy what text I want it to be?

like image 335
Skizit Avatar asked Jun 07 '11 12:06

Skizit


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.

What is Imeoption Android?

android:imeOptions="actionSend" /> You can then listen for presses on the action button by defining a TextView.OnEditorActionListener for the EditText element. In your listener, respond to the appropriate IME action ID defined in the EditorInfo class, such as IME_ACTION_SEND . For example: findViewById<EditText>(R.


2 Answers

Actually you can set custom text to that little blue button. In the xml file just use

android:imeActionLabel="whatever"

on your EditText.

Or in the java file use

etEditText.setImeActionLabel("whatever", EditorInfo.IME_ACTION_DONE);

I arbitrarily chose IME_ACTION_DONE as an example of what should go in the second parameter for this function. A full list of these actions can be found here.

It should be noted that this will not cause text to appear on all keyboards on all devices. Some keyboards do not support text on that button (e.g. swiftkey). And some devices don't support it either. A good rule is, if you see text already on the button, this will change it to whatever you'd want.

like image 51
Michael Alan Huff Avatar answered Sep 28 '22 20:09

Michael Alan Huff


You can set the InputType of your EditText View in the xml-file

<EditText
   android:id="@+id/edt_input"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:imeActionLabel="DONE"
/>

for further infos you can check the API

like image 34
dudeldidadum Avatar answered Sep 28 '22 22:09

dudeldidadum