My question pretty much speaks for itself. I want to be able to not only capture the text when selecting text in a WebView, but I also want to capture the spans surrounding the text. Is there any way to do this natively?
问问题
1199 次
1 回答
0
1 - 在 WebView 中选择文本
从扩展 WebView 的类:
public void selectAndCopyText() {
try {
Method m = WebView.class.getMethod("emulateShiftHeld", null);
m.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
// fallback
KeyEvent shiftPressEvent = new KeyEvent(0,0,
KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(this);
}
}
然后你必须使用 ClipboardManager 来观察新文本。
或者
本教程可以帮助您。
2 - 捕获跨度
这可以帮助你。
谢谢。
于 2012-07-28T00:17:12.073 回答