android 禁用剪切板_Android EditText禁止复制粘贴
1,自定义EditTextpackagecom.example.ui;importandroid.annotation.SuppressLint;importandroid.content.Context;importandroid.util.AttributeSet;importandroid.view.ActionMode;importandroid.view.Menu;importandroid.view.MenuItem;importandroid.widget.EditText;
@SuppressLint("NewApi")public class NoMenuEditText extendsEditText {private finalContext context;/*** This is a replacement method for the base TextView class' method of the
* same name. This method is used in hidden class android.widget.Editor to
* determine whether the PASTE/REPLACE popup appears when triggered from the
* text insertion handle. Returning false forces this window to never
* appear.
*
*@returnfalse*/
booleancanPaste() {return false;
}/*** This is a replacement method for the base TextView class' method of the
* same name. This method is used in hidden class android.widget.Editor to
* determine whether the PASTE/REPLACE popup appears when triggered from the
* text insertion handle. Returning false forces this window to never
* appear.
*
*@returnfalse*/@Overridepublic booleanisSuggestionsEnabled() {return false;
}publicNoMenuEditText(Context context) {super(context);this.context =context;
init();
}publicNoMenuEditText(Context context, AttributeSet attrs) {super(context, attrs);this.context =context;
init();
}public NoMenuEditText(Context context, AttributeSet attrs, intdefStyle) {super(context, attrs, defStyle);this.context =context;
init();
}private voidinit() {this.setCustomSelectionActionModeCallback(newActionModeCallbackInterceptor());this.setLongClickable(false);
}/*** Prevents the action bar (top horizontal bar with cut, copy, paste, etc.)
* from appearing by intercepting the callback that would cause it to be
* created, and returning false.*/
private class ActionModeCallbackInterceptor implementsActionMode.Callback {private final String TAG = NoMenuEditText.class.getSimpleName();public booleanonCreateActionMode(ActionMode mode, Menu menu) {return false;
}public booleanonPrepareActionMode(ActionMode mode, Menu menu) {return false;
}public booleanonActionItemClicked(ActionMode mode, MenuItem item) {return false;
}public voidonDestroyActionMode(ActionMode mode) {
}
}
}2,在layout.xml文件中这样使用
android:id="@+id/ddd"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="禁止复制粘贴" />
android 禁用剪切板_Android EditText禁止复制粘贴相关推荐
- android edittext不可复制_Android EditText禁止复制粘贴
1,自定义EditText package com.example.ui; import android.annotation.SuppressLint; import android.content ...
- Android EditText禁止复制粘贴
1,自定义EditText package com.example.ui; import android.annotation.SuppressLint; import android.content ...
- 剪切板的使用: 复制 粘贴
目录 一.MFC使用 1.将字符串复制到剪贴板中 2.获得剪贴板中字符串 二.整理封装如下: 1.复制 2.粘贴 一.MFC使用 1.将字符串复制到剪贴板中 使用OnCopy() 响应复制操作: 将字 ...
- 监听剪切板内容,解决复制粘贴内容格式错乱
我们在进行编辑东西时经常会参考一些论坛或回答,针对图片和文字都有的html文本直接复制粘贴的话就会出现文字显示重叠,或者字号异常.如果我们要重新排版的话,就需要只截取文字,然后对图片下载后重新编辑.其 ...
- 【vim】系统剪切板、vim寄存器之间的复制粘贴操作命令?系统剪切板中的内容复制粘贴到命令行?vim文本中复制粘贴到命令行
一.系统剪切板和文本内容的复制粘贴 1.1 从系统剪切板复制粘贴到文本中 需要操作3次: 分别是英文双引号.一个加号或梅花号,最后是一个p 也即"+p 或者直接使用组合键[Shift + i ...
- VNC共享剪切板,打开远程复制粘贴功能
出现原因: 本地剪切文件向服务器粘贴,发现没有粘贴内容 (服务器端执行) 1.打开任务管理器,找到rdpclip.exe 结束任务 2.任务管理器面板,①文件 ②新建任务 ③输入rdpcli ...
- android输入法剪切板历史记录,讯飞输入法剪切板功能知多少?
原标题:讯飞输入法剪切板功能知多少? 复制+粘贴"是日常操作,但批量复制时前次内容就被覆盖,粘贴很不方便:如果一次复制给多个朋友,依然需要来回操作很不省心:有时翻找上一次或者以前的聊天内容, ...
- android 剪切板广播发送者,Android使用剪切板传递数据
Android使用剪切板传递数据 发布时间:2020-08-30 14:15:07 来源:脚本之家 阅读:62 作者:Ben_love_Nicole 在Activity之间传递数据还可以利用一些技巧, ...
- 禁止复制粘贴(electron、vue)
项目中遇到非会员禁止复制粘贴,会员可以一键复制的需求 一.electron中提供了clipboard模块,用于在系统剪切板上执行复制粘贴操作 参照官方文档 clipboard.readText([ty ...
最新文章
- oracle 安装程序异常终止,Oracle安装错误“程序异常终止
- 利用对象的等待队列和锁队列管理线程。
- AI CC2018软件安装教程
- JEPaas代码———出库数量,添加明细, 确认出库
- 3-07. 求前缀表达式的值(25) (ZJU_PAT数学)
- can通讯bdc_宝马总线K-CAN3和K-CAN4常见案例
- SAP License:财务帐与后勤不一致情况
- BootstrapTable的使用教程
- 【21天python打卡】第15天 python经典案例(1)
- 英语四六级听力有线传输无线发射系统方案
- Peer Manager
- 【分享】我在名牌大学毕业后的经历
- MySQL的EXPLAIN解释器
- 开放源代码的设计层面框架Spring——day03
- Android 上 Https 双向通信— 深入理解KeyManager 和 TrustManagers
- 为什么说运维的未来必然是 AIOps?
- java计算机毕业设计二手车商城源码+mysql数据库+系统+lw文档+部署
- Linux ps命令详解,Linux查看进程
- 六成大学生认为自己毕业10年内会年入百万!
- 有关QJ_Filecenter在vue中的使用和组件封装