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 に答える