I am adding some custom menu items in the Contextual Action Menu. I need to give a web search feature with the words selected in the WebView.
I override the ActionMode using this code.
@Override
public void onActionModeStarted(ActionMode mode) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (mActionMode == null) {
mActionMode = mode;
Menu menu = mode.getMenu();
mode.getMenuInflater().inflate(R.menu.menu_search, menu);
}
}
super.onActionModeStarted(mode);
}
public void onContextualMenuItemClicked(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_search:
//HERE I WANT TO GET THE TEXT: HOW CAN I?
break;
}
if (mActionMode != null) {
mActionMode.finish();
}
}
I want to search my site using the word selected by the user in the webview, but I couln't get the way to get the selected text. How could i get that, any one please help.
Thanks in advance.