久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android:如何在 Edittext 中完全禁用復制和粘貼功能

Android: How to TOTALLY disable copy and paste function in Edittext(Android:如何在 Edittext 中完全禁用復制和粘貼功能)
本文介紹了Android:如何在 Edittext 中完全禁用復制和粘貼功能的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我對 Android 開發領域還很陌生,最近遇到了一個棘手的問題.

I am quite new to Android developing area and recently I hv encountered a tough problem.

我正在嘗試制作一個不應允許用戶從中復制內容或將內容粘貼到其中的 Edittext.我用谷歌搜索了很多,發現似乎有兩種流行的方法:

I was trying to make a Edittext which should NOT ALLOW user to copy content from or paste content to it. I hv googled a lot and find there seems to be 2 popular ways of doing so:

第一種方式,在布局文件中設置:

1st way, to set it in the layout file:

android:longClickable="false"

第二種方式,以編程方式設置它:

2nd way, to programmatically set it:

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

但我發現無論我選擇哪種方式,edittext 區域都只能被禁用長按,這會阻止用戶通過長按訪問全選,復制和粘貼"菜單.但是這兩種解決方案都沒有阻止用戶通過簡單地點擊光標來訪問粘貼"功能.

But I just found that whichever way I chose, the edittext area could only be disabled from long clickable, which then prevents user from accessing the "select all, copy and paste" menu through long clicking. But both the 2 solution DID NOT prevent the user from accessing the "paste" function through just a simple tap on the cursor.

所以我的問題是:我怎么能完全阻止用戶在某個 Edittext 中使用復制和粘貼功能.有人幫忙嗎?非常感謝

So my question is: how could I TOTALLY block user from copy and paste function in a certain Edittext. Is anyone help? Thx a lot

推薦答案

有一種可能,通過禁用游標處理程序.您將無法獲得粘貼按鈕,但您也無法通過觸摸移動光標.

There is one possibility, by disabling the cursor handler. You won't get the paste button, but you will also not be able to move the cursor with touch.

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_UP && mDisableCursorHandle) {
        // Hack to prevent keyboard and insertion handle from showing.
        cancelLongPress();
    }
    return super.onTouchEvent(event);
}

這篇關于Android:如何在 Edittext 中完全禁用復制和粘貼功能的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 欧美日韩中文字幕在线观看 | 亚洲国产福利 | 成人日韩在线 | 国产成人精品亚洲男人的天堂 | 国产福利一区二区三区 | 婷婷色在线 | 成人免费视屏 | 羞羞在线视频 | 人人插人人爽 | 国产成人综合网 | 亚洲第一免费视频 | 国产视频导航 | 免费a视频 | 精品一二三 | 国产精品免费一区二区三区 | 精品三级在线观看 | 玖玖色资源 | 国产专区在线播放 | 国产视频在线观看视频 | 福利在线 | 国产精品欧美日韩 | 欧美日视频 | 欧美三级欧美一级 | 亚洲视频免费观看 | 日韩在线免费 | 在线色网| 福利视频网址 | 国产中文字幕在线播放 | 天天操天天干天天操 | 91超碰在线播放 | 一级片在线播放 | 国产一区二区三区免费 | 麻豆亚洲一区 | 99精品成人 | 日韩视频免费看 | 欧美激情啪啪 | 久久亚洲免费视频 | 黄色在线小视频 | av在线免费观看网站 | 欧美综合色| 国产日韩视频 |