本文主要是介绍lint检查会报警告信息:(onTouchListener warning: onTouch should call View#performClick when a click is detecte,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
lint检查会报警告信息:(onTouchListener warning: onTouch should call View#performClick when a click is detected)–>onTouch在不执行touch时候应该断掉view的touch事件
错误使用:
findViewById(R.id.fl_container).setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {Tools.hideKeyboard(getActivity(), getView());getView().clearFocus();return false;}
});
解决方案:
public boolean onTouch(View v, MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_DOWN://some code....break;case MotionEvent.ACTION_UP:v.performClick();break;default:break;}return true;
}
这篇关于lint检查会报警告信息:(onTouchListener warning: onTouch should call View#performClick when a click is detecte的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!