Disable EditText context menu

前端 未结 7 1316
花落未央
花落未央 2020-11-28 13:54

I am making a vertical EditText for traditional Mongolian. I have successfully implemented it by embedding a slightly modified EditText inside of a

7条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 14:47

    This is how you block the copy paste menu from appearing in any way, shape or form. This bug really drove me crazy, and as with any Samsung bug you know its in their code but you also know they won't fix it any time soon. Anyways, here's wonder wall...

    1. Check if Android.Build.Model.toLowerCase().startsWith('sm-g930'). Do not match the whole string, the last letter is a minor version identifier. I stored this boolean in shouldBlockCopyPaste variable which comes up later.

    2. If it matches you want to block the copy paste menu from showing. This is how you ACTUALLY DO IT!!!

    Override these 2 functions, you'll notice my shouldBlockCopyPaste boolean, this is so other devices dont get blocked.

       @Override
       public ActionMode StartActionMode (ActionMode.Callback callback){
          if (shouldBlockCopyPaste) {
            return null;
          } else {
            return super.StartActionMode(callback);
          }
        }
    
       @Override
       public ActionMode StartActionMode (ActionMode.Callback callback, int type){
          if (shouldBlockCopyPaste) {
            return null;
          } else {
            return super.StartActionMode(callback, type);
          }
        }
    

提交回复
热议问题