I am really new at Java. I have been trying to allow text selection in a WebView on a long press or long touch event. I have it working like this, but it is interfering with the zoom functions of the WebView.
Does anyone know how to change MotionEvent to a long press motion event or anything similar? Keep in mind I am completely new :)
public boolean onTouchEvent(MotionEvent "ACTION_DOWN") {
try {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(webview);
} catch (Exception 开发者_开发百科e) {
throw new AssertionError(e);
}
return false;
}
Have you looked into using onLongClick instead? See View.setOnLongClickListener
Hope this helps,
Phil Lello
You can use the registerForContextMenu() for detecting longpress..
精彩评论