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

醉酒当歌 提交于 2019-12-09 09:02:24

问题


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


回答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.




回答2:


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("");



回答3:


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;
    }
});



回答4:


Try using these two lines. It may help you:

 EditText.setFocusable(false);
 EditText.setFocusableInTouchMode(false);



回答5:


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?




回答6:


@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..



来源:https://stackoverflow.com/questions/13969238/how-to-avoid-cut-copy-paste-in-smart-phone-after-rotation-port-to-land-on-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!