Reputation: 44842
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?
Upvotes: 24
Views: 18524
Reputation: 1281
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
Upvotes: 3
Reputation: 3512
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.
Upvotes: 87
Reputation: 40794
I am not sure whether it is possible to do so or not, but according to this article from the Android Developers website:
Because the IME is covering the application, it has its own editing area, which shows the text actually contained in the application. There are also some limited opportunities the application has to customize parts of the IME (the "done" button at the top and enter key label at the bottom) to improve the user experience.
So I doubt that you can change it to anything other than the pre-defined "Next", "Done", "Send", "Go" and "Search".
Upvotes: -7