onTouchListener警告:当检测到点击时,onTouch应该调用View#performClick
我已经创build了一个onTouchListener
。 不幸的是onTouch()方法throws
一个警告:
com/calculator/activitys/Calculator$1#onTouch should call View#performClick when a click is detected
这是什么意思? 我还没有find任何关于这个警告的信息。 以下是完整的代码:
LinearLayout llCalculatorContent = (LinearLayout) fragmentView.findViewById(R.id.calculator_content); llCalculatorContent.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; }