久久久久久久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問題)
主站蜘蛛池模板: 欧美啪啪网站 | 天天久久 | 三级视频网站 | 91视频在线 | 午夜影院官网 | 性高湖久久久久久久久3小时 | 国产精品1区2区 | 日韩有码一区 | 91久久国产综合久久 | 成人精品国产一区二区4080 | 久久久久久91 | 午夜激情免费视频 | 日本欧美国产在线观看 | 免费视频一区二区 | 91在线观看免费 | 99re国产| 久久久国产视频 | 欧美在线网站 | 欧美精品久久久久 | 狠狠操电影 | 国产一区不卡 | 高清国产午夜精品久久久久久 | 日韩精品视频在线 | 成人在线视频网站 | 亚洲成av人片在线观看 | 国产精品九九九 | 九九免费视频 | 日韩精品一区二区三区在线播放 | h视频在线免费看 | 在线观看视频中文字幕 | 亚洲国产精品一区 | 久久噜噜噜精品国产亚洲综合 | xxx国产精品视频 | 国产专区在线 | 伊人无码高清 | 久久最新| 国产97视频在线观看 | 欧美亚洲综合久久 | 黄色国产视频 | 欧美激情久久久 | 日韩一区欧美一区 |