After much trial and error, I have come to a reasonable solution.
Just posting it here for completeness, just in case anyone faces similar issue.
The solution was creating an alternative menu that I implemented using PopupWindow
.
And I, called this on long press event using a GestureDetector
.
myWebView.setWebChromeClient(new MyWebChromeClient());
mGestureDetector = new GestureDetector(getActivity(), new CustomGestureListener());
mGestureDetector = new GestureListener(getActivity(),myWebView);
final GestureDetector gd = new GestureDetector(getActivity(), mGestureDetector);
//====== web-view popup menu
myWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
return false;
}
});
The Gesture Listener is quite basic, code can be found here
Rest of the interaction with the web-view data is done using JavaScript, using below code, more about it can be found in google dev guide
WebView xview = (WebView)view;
xview.loadUrl("javascript:alert(showAndroidToast('underline'))");
Well this has done the job for me, result can be seen in below image, hope it helps someone.
Or unless someone has a better solution/code.
