Android的:在一个web视图禁用文本选择 [英] Android: Disable text selection in a webview
问题描述
我使用的是web视图,以present在我的应用程序的一些格式化的东西。对于一些互动(这是特定的DOM元素),我使用javascript和 WebView.addJavascriptInterface()
。现在,我想认识一个长触摸。不幸的是, onLongTouch
,在安卓2.3的手柄,文本选择显示。
I am using a webview to present some formatted stuff in my app. For some interaction (which are specific to certain dom elements) I use javascript and WebView.addJavascriptInterface()
. Now, I want to recognize a long touch. Unfortunately, onLongTouch
, in Android 2.3 the handles for text selection are displayed.
我如何关闭这个文本选择的没有的设置 onTouchListener
键,返回true? (然后,在网站的互动不再工作了。
How can I turn off this text selection without setting the onTouchListener
and return true? (Then, the interaction with the "website" doesn't work anymore.
提前最好的问候和感谢, 简奥利弗Oelerich
Best regards and thanks in advance, Jan Oliver Oelerich
推荐答案
我想它了!这是如何实现自己的longtouchlistener。在功能longTouch你可以打电话到您的JavaScript接口。
I figured it out!! This is how you can implement your own longtouchlistener. In the function longTouch you can make a call to your javascript interface.
var touching = null;
$('selector').each(function() {
this.addEventListener("touchstart", function(e) {
e.preventDefault();
touching = window.setTimeout(longTouch, 500, true);
}, false);
this.addEventListener("touchend", function(e) {
e.preventDefault();
window.clearTimeout(touching);
}, false);
});
function longTouch(e) {
// do something!
}
这工作。
这篇关于Android的:在一个web视图禁用文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!