问题
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.
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?
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