0

I want hide option Paste when click double or Long Click Edittext enter image description here

I tried:

 edtSetName.customSelectionActionModeCallback = object : ActionMode.Callback {
        override fun onCreateActionMode(p0: ActionMode?, p1: Menu?): Boolean {
            return true
        }

        override fun onPrepareActionMode(p0: ActionMode?, menu: Menu?): Boolean {
            return false
      }

        override fun onActionItemClicked(p0: ActionMode?, p1: MenuItem?): Boolean {
            return false
        }

        override fun onDestroyActionMode(p0: ActionMode?) {}
    }

But that hide all option

Ammar Abdullah
  • 802
  • 4
  • 8
  • 21
  • Check this link https://stackoverflow.com/questions/27869983/edittext-disable-paste-replace-menu-pop-up-on-text-selection-handler-click-even/28893714#28893714 – ahjo4321hsotuhsa Sep 14 '22 at 09:02

1 Answers1

0

I don't find a way to hide the menu popup, But you can disable it from pasting if the user taps on the menu

Create a custom EditText and override the onTextContextMenuItem method and return false for android.R.id.paste and android.R.id.pasteAsPlainText menu id's

@Override 
public boolean onTextContextMenuItem(int id) {
switch (id){
    case android.R.id.paste:
    case android.R.id.pasteAsPlainText:
        return false;

}
return super.onTextContextMenuItem(id);
}