Action Done in an entry dialog
android
Solution
You'll need to use `setSingleLine(true)` rather than `setLines(1)` and then you need an `EditorActionListener` to catch the `Done` key.
editText.setSingleLine(true);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Toast.makeText(MainActivity.this, "Got IME Done", Toast.LENGTH_SHORT).show();
return true;
}
});
Problem
I have a standard entry popup dialog ``` AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(title) .setMessage(message) .setPositiveButton(buttonPositif, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Send the positive button event back to the host activity mListener.onDialogPositiveClick(EntryDialogFacade.this); } }) .setNegativeButton(buttonNegatif, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Send the negative button event back to the host activity mListener.onDialogNegativeClick(EntryDialogFacade.this); } }); editText = new EditText(activity); editText.setLines(1); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); builder.setView(editText); Dialog dialog = builder.create(); dialog.show(); ``` I am trying to show the Done button on the entry field keyboard (see code snippet), however, this is not working this way. Would have anyone experienced the same thing? Cheers.