2

We can disable editing text in EditText like this https://stackoverflow.com/a/8942552/7767664d

EditText.setFocusable(false)

But still we can paste some text to this view when you do long tap on it and paste button pops up

enter image description here

user924
  • 5,286
  • 3
  • 35
  • 97

3 Answers3

1

Otherwise disable long click on edittext :

EditText.setLongClickable(false);

or directly in the xml:

android:longClickable="false"
Ashish
  • 6,494
  • 3
  • 21
  • 42
1

JAVA

editTextOBJ.setLongClickable(false);
editTextOBJ.setTextIsSelectable(false);

XML

 android:longClickable="false"
 android:textIsSelectable="false"
IntelliJ Amiya
  • 73,189
  • 14
  • 161
  • 193
-1
edittext.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;
            }
        });
Flying Dutchman
  • 335
  • 5
  • 12