自定义视图'ImageButton'已调用setOnTouchListener,但不会覆盖performClick [英] Custom view 'ImageButton' has setOnTouchListener called on it but does not override performClick
问题描述
嗯,我知道这个警告有一些问题,但我仍然无法弄清楚如何摆脱这个。
我不想在类级别实现 OnTouchListener
接口,因为有很多按钮,我更喜欢将每一段代码保存在他自己的空间 。
我在 ACTION_UP
之后添加了 performClick()
,但警告仍然存在。
Well, I know there are some questions regarding this warning, but i still cannot figure out how to get rid of this.
I don't want to implement the OnTouchListener
interface on class level, because there are many buttons and i prefer to keep every piece of code on his own "space".
I added performClick()
after ACTION_UP
case but the warning still persist.
谢谢
send.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_UP:
view.performClick();
break;
default:
break;
}
return true;
}
});
推荐答案
如果你确定你的代码没问题代码就像您想要的那样,您可以在以下位置禁用此类警告:文件 - > 设置 - > 编辑 - > 检查 - > Android - > Lint - > 辅助功能 - > 自定义视图中的辅助功能
Your code is OK, if you are sure that your code works like you want, you can just disable this kind of warnings in: File -> Settings -> Editor -> Inspections -> Android -> Lint -> Accessibility -> Accessibility in Custom Views
这篇关于自定义视图'ImageButton'已调用setOnTouchListener,但不会覆盖performClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!