How to select text or highlight text in webview android 3.1 while clicking menu? I have implemented but it's not working. can anybody tell how to do it?
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case SELECTTEXT_MENU_ID:
//SelectText();
System.out.println("entering menu");
selectAndCopyText();
return true;
}
return true;
}
public void selectAndCopyText()
{
try
{
Method m = WebView.class.getMethod("emulateShiftHeld", null);
m.invoke(webview, null);
} catch (Exception e)
{
e.printStackTrace(); // fallback
KeyEvent shiftPressEvent = new KeyEvent(0,0, KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(webview);
}
}
Thanks for your help