onTouchListener warning: onTouch should call View#performClick when a click is detected

android, ontouchlistener

Solution

Here you go:

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;
}

Problem

I have created a `onTouchListener`. Unfortunately onTouch() method `throws` me a warning: ``` com/calculator/activitys/Calculator$1#onTouch should call View#performClick when a click is detected ``` What does it mean? I have not found any information about this warn. Here is the full code: ``` 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; } }); ```

Original source

Related problems