Android的文本选择在web视图 [英] Android Text Selection In Webview
本文介绍了Android的文本选择在web视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的WebView在Android的蜂窝(3.X)显示内容。我创建了切定制操作菜单,复制和paste.How我可以复制选定的文本在web视图通过我的自定义操作菜单。
I am using webview for displaying content in Android Honeycomb(3.x). I created customized action menu for cut,copy and paste.How can i copy the selected text in Webview by using my customized action menu.
推荐答案
也许这将有助于...
May It Will Help...
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);
}
}
从 http://stackoverflow.com/a/1113204/638987
这篇关于Android的文本选择在web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文