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() {
@Override
public 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;
}