I used the solution given by Erel:
For Android 4 devices the "context menu" is not changed but it doesn't matter.
For Android >= 5 it works except for the menu item "select all"
Custom Context Menu for Text Selection
This example uses inline Java with JavaObject to allow creating custom context menus when the user selects text. To use it in your project you need to add the inline Java code and implement this method: Sub ContextMenu_Create(ActionMode As JavaObject, FocusedView As View) Dim menu As...
www.b4x.com
B4X:
Sub ContextMenu_Create(AM As JavaObject, Fw As View)
ActionMode=AM
FocusedView=Fw
Dim menu As JavaObject = ActionMode.RunMethod("getMenu", Null)
menu.RunMethod("clear", Null)
End Sub
#if Java
import android.view.*;
import anywheresoftware.b4a.AbsObjectWrapper;
import android.text.Selection;
import android.widget.EditText;
@Override
public void onActionModeStarted(ActionMode mode) {
processBA.raiseEvent(this, "contextmenu_create", AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), mode),
AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.ConcreteViewWrapper(), getCurrentFocus()));
super.onActionModeStarted(mode);
}
@Override
public void onActionModeFinished(ActionMode mode) {
super.onActionModeFinished(mode);
}
public static int getSelectionLength(EditText et) {
return Selection.getSelectionEnd(et.getText()) - Selection.getSelectionStart(et.getText());
}
#End If
For Android 4 devices the "context menu" is not changed but it doesn't matter.
For Android >= 5 it works except for the menu item "select all"