14

I am working on to avoid cut/copy/paste in smart phone (for tablet its fine). Its fine in port mode but coming in land mode EditText shows a Button Next. after selecting the text, next button converts into Edit Button which has copy,cut and paste option.

So is there any way to disable cut/copy after rotation when edit button appears.

i am following this link. How to disable copy/paste from/to EditText

This image with out text select

After select

Community
  • 1
  • 1
Monty
  • 3,205
  • 8
  • 36
  • 61

6 Answers6

1

I think you can use this:

http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeOptions

With the flag:

flagNoAccessoryAction

Used in conjunction with a custom action, this indicates that the action should not be available as an accessory button when the input method is full-screen. Note that by setting this flag, there can be cases where the action is simply never available to the user. Setting this generally means that you think showing text being edited is more important than the action you have supplied. Corresponds to IME_FLAG_NO_ACCESSORY_ACTION.

neteinstein
  • 17,529
  • 11
  • 93
  • 123
  • Thanks for answer. i have tested this but according to my functionality Next button should be there .after using this nothing is there only text,. – Monty Dec 31 '12 at 05:34
  • By having the button there I think you can't stop copy paste, as it is replaced by those functionalities as soon as you select text.. – neteinstein Jan 01 '13 at 21:17
  • This is default behavior of jelly bean .we want next button but do not want this Next button change to Edit after select the text. – Monty Jan 02 '13 at 03:32
1

I would insist you to disable the long click on the EditText as that Edit button appears when you long press on the selected text in the EditText.

et_text.setLongClickable(false);

Also, you can clear the ClipboardManager, so that if you already have something that is already copied to ClipBoard will be cleared using,

ClipboardManager manager = (ClipboardManager) 
                                 getSystemService(Context.CLIPBOARD_SERVICE);
manager.setText("");
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
  • thanks for reply .i think ClipboardManger is deprecated in 3.2 or greater version. – Monty Dec 31 '12 at 06:23
  • Deprecated class is `import android.text.ClipboardManager` but you can use `import android.content.ClipboardManager`, also setting long click false should work on EditText. – Lalit Poptani Dec 31 '12 at 06:31
  • No longclick not working ,i have tested again and again..i am using 4.0.3 version and using google nexus – Monty Dec 31 '12 at 06:48
  • edittext.setLongClickable(false); ClipboardManager maner = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); maner.setText("");..code – Monty Dec 31 '12 at 06:50
0

Try this ..

your_edit_text.setCustomSelectionActionModeCallback(new 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;
    }
});
lonesomeday
  • 233,373
  • 50
  • 316
  • 318
AndroidHacker
  • 3,596
  • 1
  • 25
  • 45
0

Try using these two lines. It may help you:

 EditText.setFocusable(false);
 EditText.setFocusableInTouchMode(false);
akshay
  • 5,811
  • 5
  • 39
  • 58
-1

@Cobra - set EditText.setEditable(false); in your code, or you set this property in your xml as well. this property done well, but if any case this won't work ..set setFocusable also false.. this solution work for me..

Manish
  • 1,259
  • 3
  • 11
  • 20
  • Not working..becouse in my case i need to set the value every time im my edittext.after using this i am not able to touch my edit text. – Monty Dec 21 '12 at 09:33
  • i already mention i am using jelly bean..may be this is not working in this version. – Monty Dec 21 '12 at 09:53
  • by the way after using EditText.setEnable(false); .you are able to give input in that particular edit text. if yes then you are great. – Monty Dec 21 '12 at 09:55
-1

as we don't know what u tried so far..and what you actually doing in your code...beside that..here is a link ...similar to your question , i think this will help you out.. Disabling the fullscreen editing view for soft keyboard input in landscape?

Community
  • 1
  • 1
Manish
  • 1,259
  • 3
  • 11
  • 20