本文介绍了onLongClickListener 不适用于 WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下结构来实现 longclicklistener.如果我单击包含 html 链接的 webview 上的文本,它会起作用,所以我知道结构并非完全错误.
I have the following struktur to implement an longclicklistener. It works if I click on a text on the webview which contains a html-link, so I know the structure is not completely wrong.
我现在删除了这个链接,听众不再听点击了.有没有人知道这个问题并有一些建议?
I removed this link now and the listener just doesn't listen to clicks anymore. Does anybody know this problem and have some advices?
private View.OnLongClickListener mLongClickHandler = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
...
return true;
}
};
...
mywebview.setOnLongClickListener(mLongClickHandler);
推荐答案
我现在尝试自己克隆 longclick 操作.这有效,但只有几次.一段时间后,不再调用 onTouch-Event... 建议?
I tried now to clone the longclick action by myself. This works but only a few times. After a certain time, the onTouch-Event is not called anymore... Suggestions?
private Runnable copyTextAfterDelay=new Runnable() {
public void run() {
...
}
};
...
myWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
mTimerHandler.postDelayed(copyTextAfterDelay,1000);
break;
case MotionEvent.ACTION_UP:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
break;
case MotionEvent.ACTION_MOVE:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
break;
}
return false;
}
});
这篇关于onLongClickListener 不适用于 WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!