I have a webView. WebView shows html with text, images, buttons etc.
I want to make few things.
1) That user can not select text in webView
2) The same behavior of click and long click by button.
I made next things for resolve my problems: First of all, I added to html page style:
body {
...
-webkit-user-select: none;
-webkit-touch-callout: none;
...
}
But it didn't help me. This solution didn't work on all androids.
So I tried to add touch listener to webView.
Code of listener:
webView.setOnTouchListener(new OnTouchListener() {
private float prevX;
private float prevY;
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean handled = true;
if (MotionEvent.ACTION_DOWN == event.getAction()) {
prevX = event.getX();
prevY = event.getY();
} else if (MotionEvent.ACTION_UP == event.getAction()) {
if (Math.abs(event.getX() - prevX) < 50
&& Math.abs(event.getY() - prevY) < 50) {
handled = (event.getEventTime() - event
.getDownTime()) > 200;
}
}
Log.d("-------------------------------------------------", ""+handled);
return handled;
}
});
But this didn't work either, may be I made something wrong? After that I tried to add long click listener:
webView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
v.performClick();
return true;
}
});
This solution solves only the first problem.
So, where did I go wrong?