I have an requirement where EditText
doesn't allow paste but it should allow copy.
I tried setCustomSelectionActionModeCallback
but it disable copy option.
EditText etxt = (EditText) findViewById(R.id.editText1);
etxt.setCustomSelectionActionModeCallback(new 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;
}
});
If you want to disable only the paste option, I think it is better to remove the
paste context menu
item, this is a util method I implemented in my apps to achieve that (I also removed cut item)I done my self..credit goes to Android intercept paste\copy\cut on editText
I just changed onTextContextMenuItem() based on my requirement..
If you are using API level 11 or above use this