How can I get a "done" button in softkeyboard?
add this to your EditText xml:
android:imeOptions="actionDone"
or, to set it from code:
yourEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
for more, read this
In my Intel x86 Emulator at least, the "Done" key appears only if you specify the input type: "phone", "number", "text", "textPassword", ... with android:inputType. If you don't specify any or you set "textMultiLine", "Done" does not appear.
android:imeOptions="actionDone"
and
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
seem useless, since they don't change anything either in the first case (where "Done" appears anyway) or in the in the second case (since "Done" keeps not appearing) !
Using my Galaxy S2 phone
For the code below, each EditText will have a Return button that adds a new line:
EditText editText = new EditText(this);
For the code below, each EditText will have a Next button that navigates to the next field and the last one will have Done button that will dismiss the keyboard:
EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_TEXT);
For the code below, no change, each EditText has a Return button:
EditText editText = new EditText(this);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
For the code below, all EditText will have a Done button and all will dismiss the keyboard.
EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_TEXT);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
For layouts use code below:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:imeOptions="actionDone"/>