0

I have customised the selection menu for an EDITTEXT element in an activity which displays a form to replace COPY, PASTE etc with actions that automatically copy and paste selected text to defined EDITTEXT elements. It's based on this solution which uses

setCustomSelectionActionModeCallback(new ActionMode.Callback()... 

onPrepareActionMode(ActionMode mode, Menu menu)

This works well in portrait mode, however in landscape mode, a full-screen soft keyboard is displayed (with a NEXT / DONE button) which seems to override my custom menu with the default options COPY/PASTE etc.

Will P
  • 419
  • 5
  • 8

1 Answers1

0

I have overcome this issue by invoking setShowSoftInputOnFocus(false) which allows my custom menu to be displayed when text is selected, however it does not prevent the soft keyboard from being displayed when the view gets focus.

public boolean onCreateActionMode(ActionMode mode, Menu menu) { // TODO Auto-generated method stub

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                editTextDescription.setShowSoftInputOnFocus(false);
            }
            return true;
        }

My solution does the job so it may be of use to someone facing the same issue. Is there a cleaner method for retaining custom selection menu functionality in landscape orientation? and why does the soft keyboard display dispite setting the view's ShowSoftInputOnFocus to false?

Will P
  • 419
  • 5
  • 8
  • Facing the same problem. This seems like a bug in Android - the soft input should NOT show when `ShowSoftInputOnFocus` is false, even in landscape mode. – Bip901 Oct 12 '21 at 10:37