disable Copy Paste Operations for EditText - Android android.widget

Android examples for android.widget:EditText

Description

disable Copy Paste Operations for EditText

Demo Code

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;

public class Main{

    public static void disableCopyPasteOperations(EditText editText) {
        editText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

            public boolean onCreateActionMode(ActionMode actionMode,
                    Menu menu) {//from w ww .  j  a  v  a 2s .  c  om
                return false;
            }

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

            public boolean onActionItemClicked(ActionMode actionMode,
                    MenuItem item) {
                return false;
            }

            public void onDestroyActionMode(ActionMode actionMode) {
            }
        });

        editText.setLongClickable(false);
        editText.setTextIsSelectable(false);
    }

}

Related Tutorials