1

I want to disable copy/cut options in editText, for this, I googled and found some good solutions from here How to disable copy/paste from/to EditText, but none of this solutions is working when editText is in full-screen mode in Landscape orientation, Please help me to fix this issue, Thanks in Advance

enter image description here

Note: Similar question already asked here How to avoid cut/copy/paste in smart phone after rotation port to land on Android4.X? long back, since solution not yet found I was asking again

1 Answers1

1

You can use setLongClickable(false); for the edittext when the orientation is changed.

Try adding this in your activity

@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;
}
Jyoti JK
  • 2,141
  • 1
  • 17
  • 40