Reputation: 4953
I'm developing app for Android smartphones >= 2.1 with WebView. Webview contains page with text data.
I want to let a user select a text in WebView and then highlight it.
I realized selection, via emulateShiftHeld(), but it stupid copies selected text into Clipboard.
Can I set JS callback for selection finished event inside page html?
Or, may be, in Java set a WebView's listener for the same?
Thank you
Upvotes: 2
Views: 3989
Reputation: 41
I am using a github project called BTAndroidWebViewSelection to get web view selections working in 2.2 - 4.0.3. This project uses a javascript interface that gets all touches passed to it. The solution seems to work pretty well. This github project includes the necessary javascript files in the assets folder as well as a test page and a WebView
that loads the test page and implements all necessary methods to handle the selection.
Upvotes: 4