1

I am working in xamarin forms to create an app for android. I want to disable the copy/paste functionality of textbox in android. I used the following line to disable it

   Control.LongClickable = false;

But its working only in case of if user press the text for long time. But if user click multiple times on text, he becomes able to copy paste. How I can completely disable the copy paste functionality of textbox?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
anand
  • 1,399
  • 5
  • 23
  • 55
  • 1
    Possible duplicate of http://stackoverflow.com/questions/37684515/disable-copy-paste-on-xamarin-forms-input-field-i-e-entry – Smit Aug 12 '16 at 05:01

2 Answers2

1

In eclipse this can be used, Just check will it be helpful.

textView.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
        return false;
    }

    public void onDestroyActionMode(ActionMode mode) {                  
    }

    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        return false;
    }

    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        return false;
    }
});
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Shiv Buyya
  • 3,770
  • 2
  • 30
  • 25
1
// after onCreateView and findById you you_editText view;
you_editText.CustomSelectionActionModeCallback = new CopyPasteDisabler();    

class CopyPasteDisabler : Java.Lang.Object, Android.Views.ActionMode.ICallback
{
    public bool OnActionItemClicked(Android.Views.ActionMode mode, IMenuItem item) => false;
    public bool OnCreateActionMode(Android.Views.ActionMode mode, IMenu menu) => false;
    public void OnDestroyActionMode(Android.Views.ActionMode mode) {}
    public bool OnPrepareActionMode(Android.Views.ActionMode mode, IMenu menu) => false;
}
Jacob
  • 81
  • 1
  • 6