无论如何,有没有要从视图对象中删除onTouchListener? [英] Is there anyway to remove an onTouchListener from a view object?
问题描述
我有一个用于Webview的触摸式侦听器,但是它对Webview的功能有不好的影响,所以我想知道在最初的交互之后是否还有删除触摸式侦听器的方法?
I have an on touch listener for a webview, but it has a bad effect on the functionality of the webview, so I am wondering if there is anyway to removed the on touch listener after the initial interaction?
推荐答案
因此,在您进行活动时,您将设置覆盖的onTouchListener:
So in you activity you would set your overridden onTouchListener:
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.setOnTouchListener(mWebView.mOnTouchListener);
return false;
}
});
您将必须创建一个新类,扩展WebView.然后在其中定义一个OnTouchListener.
And you would have to make a new class, extending WebView. And within it you would define an OnTouchListener.
public final OnTouchListener mOnTouchListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent rawEvent) {
return false;
}
};
将ontouchlistener设置为null不会将其重置为默认定义.您仍然必须提供一个实际的侦听器.
Setting the ontouchlistener to null doesn't reset it to the default definition. You still have to provide an actual listener.
这篇关于无论如何,有没有要从视图对象中删除onTouchListener?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!