I’ve got a ListActivity that displays WebViews.
There is a menu option to copy text that will call this on visible WebViews.
Everything works except for one thing. I can’t perform text selection in vertical direction as ListView consumes corresponding MotionEvents for it’s own scrolling.
I’ve tried this:
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (webViewsInTextSelectionMode) {
bypassEventToWebViews(ev);
return true;
} else {
return super.dispatchTouchEvent(ev);
}
}
Which will block scrolling but will also pass unadjusted MotionEvent coordinates to a WebView.
Is there a way to correctly prevent ListView from scrolling in this case?
This is a complete shot in the dark and most likely won’t work but probably worth a try. You can try calling
ViewParent#requestDisallowInterceptTouchEventon the parentListViewinside of theViewGroupcontaining yourWebView. You’ll have to call that every time there is a down motion event for the duration of the text selection. This is because the flag is reset on a up/cancel motion event.If that doesn’t work you’ll probably have to create your own copy of ListView and modify it appropriately. This isn’t too daunting, you’ll have to copy all classes in the class hierarchy back to
AdapterViewand fix the copied AdapterView class (mainly use of private/package level member variables that have protected/public accessors functions).