解决方法
从扩展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,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0); shiftPressEvent.dispatch(this); } }
然后你必须使用ClipboardManager来监视新文本.
适用于Android 1.5 – 2.3. emulateShiftHeld()自2.2起公开.