disable Copy Paste Operations on EditText - Android User Interface

Android examples for User Interface:EditText

Description

disable Copy Paste Operations on EditText

Demo Code


//package com.java2s;

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) {/*  w  w w.j av  a 2  s  .  co  m*/
                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