久久久久久久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問題)
主站蜘蛛池模板: 亚洲美女一区 | 欧美一级艳情片免费观看 | 久久日韩精品 | 天天插天天操 | 日韩精品久久 | 久久久新视频 | 黄色一级大片视频 | 日韩久久久久 | 国产精品久久久久久久久久免费看 | 日日干夜夜操天天操 | 精品毛片在线观看 | 亚洲国产成人在线视频 | 老外几下就让我高潮了 | 亚洲精品综合一区二区 | 久久久久久中文字幕 | 久久久久久久久综合 | 亚洲免费成人 | 日本久久网 | 欧美一区二区成人 | 国产成人精品综合 | 毛片免费观看视频 | 色久在线| 免费国产黄网站在线观看视频 | 国产在线观看一区二区三区 | 国产精品久久一区 | 欧美精品一区二区三区在线 | 精品久草 | 亚洲精品3| 久久综合久色欧美综合狠狠 | 国产精品91久久久久久 | 成人精品国产一区二区4080 | 欧美日韩在线免费观看 | 在线视频一区二区 | 91不卡| www.伊人.com | 亚洲精品在线免费观看视频 | 欧美涩| www.国产一区| 激情91| 日韩一区二区在线视频 | 一区二区三区影院 |