Skip to content

Instantly share code, notes, and snippets.

@foxanna
Created September 17, 2018 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxanna/0690fc6717e49b34e3c5e53abb8ef3df to your computer and use it in GitHub Desktop.
Save foxanna/0690fc6717e49b34e3c5e53abb8ef3df to your computer and use it in GitHub Desktop.
public class CustomSelectionActionModeCallback implements ActionMode.Callback {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
try {
MenuItem copyItem = menu.findItem(android.R.id.copy);
CharSequence title = copyItem.getTitle();
menu.clear();
menu.add(0, android.R.id.copy, 0, title);
}
catch (Exception e) {
// ignored
}
return true;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment