onLongClickListener不能在web视图工作 [英] onLongClickListener does not work on WebView
问题描述
我有以下struktur实现一个longclicklistener。如果我点击上包含一个HTML链接web视图文本它的工作原理,所以我知道的结构是不是完全错误的。
我删除了这个链接现在听众就是不听点击了。有谁知道这个问题,有一些建议?
私人View.OnLongClickListener mLongClickHandler =新View.OnLongClickListener(){
@覆盖
公共布尔onLongClick(查看视图){
...
返回true;
}
};
...
mywebview.setOnLongClickListener(mLongClickHandler);
我想现在自己克隆longclick行动。这工作,但只有几次。经过一定时间后,onTouch-事件不叫了...建议?
私人可运行copyTextAfterDelay =新的Runnable(){
公共无效的run(){
...
}
};
...
myWebView.setOnTouchListener(新View.OnTouchListener(){
@覆盖
公共布尔onTouch(视图V,MotionEvent事件){
开关(event.getAction()){
案例MotionEvent.ACTION_DOWN:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
mTimerHandler.postDelayed(copyTextAfterDelay,1000);
打破;
案例MotionEvent.ACTION_UP:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
打破;
案例MotionEvent.ACTION_MOVE:
mTimerHandler.removeCallbacks(copyTextAfterDelay);
打破;
}
返回false;
}
});
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);
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不能在web视图工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!