i want to provide custom handlers that cut,copy text.
Target on Longclick
Finally I have sorted this out. This solution perfectly works for me. First of all, you need to create the context menu background as follows
menuback.xml
-
Then Create your Custom Menu as follows
mymenu.xml
Now add the following lines on your
styles.xml
And Finally set elevation of the actionbar to 0 and implement the ActionMode.CallBack as follows
EditText editText=findViewById(R.id.ed);
getSupportActionBar().setElevation(0);
editText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenu().clear();
MenuInflater inflater=mode.getMenuInflater();
inflater.inflate(R.menu.mymenu,menu);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
Ta...da... Here is the Final Result