i want to provide custom handlers that cut,copy text.
Target on Longclick
- Context Menu Should not appear.
- Text could get selected with trackers ( or Draggers ).
[UPDATE]
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edittext = (EditText) findViewById(R.id.notetext);
. . . .
edittext.setCustomSelectionActionModeCallback(new ActionMode.Callback()
{
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu)
{
return true;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
. . . .
}
@Override
public void onSupportActionModeStarted(android.support.v7.view.ActionMode mode) {
super.onSupportActionModeStarted(mode);
View v = new View(MainActivity.this);
mode.setCustomView(v);
mode.getMenu().clear();
mode.getMenu().close();
mode.finish();
}
Using above piece of code i am able to remove Select All, Cut, Copy and Paste.But Still it shows "Text Selection"
Below Image shows what is required.
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
Ta...da... Here is the Final Result
you want to get rid of the ActionMode? and create your own??
you can override this and get notified when the default is about to be displayed
if you want to close it then you call
mode.finish();
you can call it there to close if or finish it if you do not need it.when it is about to die it calls this onSupportActionModeFinished(ActionMode mode)` the methods i have stated are for the support libraries, hope you know that.
The rest is cheese