Issue
I have a hybrid app made with Svelte + capacitor. In the app we are loading digital book and we are showing custom context/tooltip menu on text selection. It is working fine on Web & Desktop apps but not on Android. On Android it is showing android default menu (copy/ paste etc). We need to disable default android text selection menu.
Tried below code
mWebView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return true;
}
});
mWebView.setLongClickable(false);
Solution
In order to hide default text selection menu, we need to override the default behaviour of android action mode.
By adding these 2 methods in MainActivity, you can hide the default text selection menu in Android.
@Override
public void onActionModeStarted(ActionMode mode) {
if (mActionMode == null) {
mActionMode = mode;
Menu menu = mode.getMenu();
menu.clear();
}
super.onActionModeStarted(mode);
}
@Override
public void onActionModeFinished(ActionMode mode) {
mActionMode = null;
super.onActionModeFinished(mode);
}
Answered By - RajuPedda
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.