Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Text Selection In Webview

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.

like image 492
Dinesh Avatar asked May 04 '12 12:05

Dinesh


1 Answers

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); } 

}

Got from https://stackoverflow.com/a/1113204/638987

like image 120
Surej Avatar answered Oct 06 '22 00:10

Surej