1,自定义EditText
package com.example.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;@SuppressLint("NewApi")
public class NoMenuEditText extends EditText {
private final Context 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.
*
* @return false
*/
boolean canPaste() {
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.
*
* @return false
*/
@Override
public boolean isSuggestionsEnabled() {
return false;
}public NoMenuEditText(Context context) {
super(context);
this.context = context;
init();
}public NoMenuEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
init();
}public NoMenuEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
init();
}private void init() {
this.setCustomSelectionActionModeCallback(new ActionModeCallbackInterceptor());
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 implements ActionMode.Callback {
private final String TAG = NoMenuEditText.class.getSimpleName();public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}public void onDestroyActionMode(ActionMode mode) {
}
}
}
2,在layout.xml文件中这样使用
<com.example.ui.NoMenuEditText
android:id="@+id/ddd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="禁止复制粘贴" />

Android EditText禁止复制粘贴相关推荐

  1. android 禁用剪切板_Android EditText禁止复制粘贴

    1,自定义EditTextpackagecom.example.ui;importandroid.annotation.SuppressLint;importandroid.content.Conte ...

  2. android edittext不可复制_Android EditText禁止复制粘贴

    1,自定义EditText package com.example.ui; import android.annotation.SuppressLint; import android.content ...

  3. html页面怎样禁止复制粘贴,javascript中如何禁止复制粘贴?

    在javascript中可以使用oncopy事件和onpaste事件来实现禁止复制粘贴的功能.oncopy事件会在用户拷贝元素上内容时被触发:onpaste事件在用户向元素中粘贴文本时触发. java ...

  4. Web Security——英语写作与教学评价系统(iWrite)解决写作时禁止复制粘贴问题解决方案

    基本概念 英语写作与教学评价系统(iWrite):英语写作教学与评阅系统基于对大学英语写作教学的深入研究而设计,能够实现语言.内容.篇章结构及技术规范四个维度的机器智能评阅,并将机评和人评深度结合,以 ...

  5. 禁止复制粘贴_网页禁止复制粘贴? 教你5招, 绕过网页限制, 免费复制全网内容!...

    转自:大大白菜装机 说到网页禁止复制粘贴,相信很多人都有过这种经历:在网上辛辛苦苦地去查找一些资料,好不容易找到了,但是不能复制,真是"竹篮打水一场空"! 因此,难倒许多人的问题就 ...

  6. 第十八期:网页禁止复制粘贴怎么办?教你六招轻松搞定

    经常在网上遇到一些无法复制的文章,那么问题来了,有什么办法可以绕开这种限制,将网页内容轻松下载回来呢? 经常在网上遇到一些无法复制的文章,那么问题来了,有什么办法可以绕开这种限制,将网页内容轻松下载回 ...

  7. hikvision v2.3控件网页demo_网页禁止复制粘贴怎么解决?教你五招轻松搞定

    经常在网上遇到一些无法复制的文章,有什么办法可以绕开这种限制,将网页内容轻松下载下来呢?其实网页上文本复制下来不是问题,只要用对方法,都可以轻松搞定,将相关文本复制下来,一起来看看要怎么做吧. 方法一 ...

  8. 禁止html页面无法粘贴复制,javascript中如何禁止复制粘贴?

    在javascript中可以使用oncopy事件和onpaste事件来实现禁止复制粘贴的功能.oncopy事件会在用户拷贝元素上内容时被触发:onpaste事件在用户向元素中粘贴文本时触发. java ...

  9. Android实现一键复制粘贴,兼容低版本系统(api 11以下)

    Android实现一键复制粘贴,兼容低版本系统(api11以下) /**         * 实现文本复制功能         * @param content         * @return t ...

最新文章

  1. 高级网络配置《 bond team桥接 》的建立
  2. 自己做的一个固定大小对象内存池,效率大概为原始的new/delete的2倍
  3. 关于FactoryBean 和BeanFactory
  4. 离线安装Eclipse的Color theme plugin
  5. XP系统安装SQL2000企业版开启1433端口
  6. Bootstrap静态cdn
  7. python memoryview_memoryview的用法
  8. python队列及其实现
  9. C#学习你需要知道的---(For和Foreach)
  10. python增删改查mysql_Python操作MySQL(增删改查)
  11. [HDOJ1823] Luck and Love(线段树,树套树)
  12. linux——windows:上传、下载命令——rz,sz
  13. Observer(观察者)模式
  14. Vue之路由beforeEach
  15. python标准库 —— os模块
  16. Linux gd库安装步骤说明
  17. 工业汽轮机调节系统的模糊PID控制器
  18. 【AndroidStudio】手机QQ登录界面2022版
  19. 【数据挖掘】K-Means 一维数据聚类分析示例
  20. 【Netty之进阶篇】

热门文章

  1. 学生电脑哪个牌子好_柳州304不锈钢学生饭盒哪个牌子好_家典美日用品
  2. 服务器策略文件,如何解决服务器对文件请求的缓存策略教程
  3. python dash库_让你事半功倍的小众 Python 库
  4. 计算机组装维护的概念,实用计算机组装与维护库及概念.doc
  5. include详解 shell_Linux 系统结构详解,看这一篇就够了
  6. 手机4k读写速度测试软件,4K扇区速度测试及读写IOPS_Intel 520_固态硬盘评测-中关村在线...
  7. python实战项目_11 个实战项目,掌握 Python 数据可视化
  8. 详解Linux多线程编程
  9. 将你的Apache速度提高十倍的经验分享
  10. golang 中 map 转 struct