1

我想禁用 editText 中的复制/剪切选项,为此,我用谷歌搜索并从这里找到了一些好的解决方案How to disable copy/paste from/to EditText,但是当 editText 处于全屏模式时,这些解决方案都不起作用横向,请帮我解决这个问题,在此先感谢

在此处输入图像描述

注意:类似的问题已经在这里问过如何避免在旋转端口登陆Android4.X后在智能手机中剪切/复制/粘贴?很久以前,由于尚未找到解决方案,我再次询问

4

1 回答 1

0

setLongClickable(false);当方向改变时,您可以用于编辑文本。

尝试将其添加到您的活动中

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE && isFullScreen()) {
        edittext.setLongClickable(false);
    } else {
       edittext.setLongClickable(true);
    }
}

public boolean isFullScreen() {
  int flg = getWindow().getAttributes().flags;
  boolean flag = false;       
  if ((flg & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
      flag = true;
  }
  return flag;
}
于 2018-05-15T09:15:32.790 回答