How to avoid cut/copy/paste in smart phone after rotation port to land on Android4.X?
Asked Answered
D

6

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

Displant answered 20/12, 2012 at 9:45 Comment(2)
I am using Google Nexus smart phone.Displant
NO answer coming for this question.Displant
E
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.

Epiboly answered 28/12, 2012 at 14:39 Comment(3)
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,.Displant
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..Epiboly
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.Displant
G
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("");
Gaussmeter answered 31/12, 2012 at 6:16 Comment(4)
thanks for reply .i think ClipboardManger is deprecated in 3.2 or greater version.Displant
Deprecated class is import android.text.ClipboardManager but you can use import android.content.ClipboardManager, also setting long click false should work on EditText.Gaussmeter
No longclick not working ,i have tested again and again..i am using 4.0.3 version and using google nexusDisplant
edittext.setLongClickable(false); ClipboardManager maner = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); maner.setText("");..codeDisplant
E
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;
    }
});
Expectancy answered 1/11, 2013 at 10:20 Comment(0)
P
0

Try using these two lines. It may help you:

 EditText.setFocusable(false);
 EditText.setFocusableInTouchMode(false);
Pecksniffian answered 19/12, 2013 at 8:52 Comment(0)
D
-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..

Darra answered 21/12, 2012 at 8:55 Comment(3)
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.Displant
i already mention i am using jelly bean..may be this is not working in this version.Displant
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.Displant
D
-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?

Darra answered 21/12, 2012 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.