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?
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: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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With