how to select a word in android webview?

匆匆过客 提交于 2019-12-05 03:06:18

问题


I want to implement this function: when user longpress a word in webview, I can get the word to do something, I search and found that: 1. android 2.3+'s webview sdk do provide this function which when long press, it highlights the word and brings up the start and end selection cursor. but under 2.3 it only provides the emulateshift function to select words and paste to clipboard, which is very ugly.

  1. does anybody can ever get the cursor while click on the text field of the webview? I can't find any methods like getSelectionStart(() in WebView, does it mean that there is no way to get the current cursor?

  2. I know that even on 2.3, when user long presses, android change the webview into a temporary WebTextView mode which can let the user to select, but it is a private class, I try to recreate a class like that,but it is very complicated and no way to get things done.

has anybody successfully implement this? thank you.


回答1:


That is unfortunately close to impossible. It is a function embedded deep in the system and you would first have to have a rooted phone and then tinker with the rom itself.



来源:https://stackoverflow.com/questions/8034369/how-to-select-a-word-in-android-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!