Custom view … overrides onTouchEvent but not performClick

前端 未结 3 1069
半阙折子戏
半阙折子戏 2020-12-13 06:38

I get this warning (from the question title) in a custom Android view I am developing.

Why do I get warned? What\'s the logic behind it i.e. why is it a good
pra

3条回答
  •  醉酒成梦
    2020-12-13 06:43

    This warning tells you to override performClick

    @Override
     public boolean performClick() {
      // Calls the super implementation, which generates an AccessibilityEvent
            // and calls the onClick() listener on the view, if any
            super.performClick();
    
            // Handle the action for the custom click here
    
            return true;
     }
    

    But it is not compulsory. As I have created a custom knobView and it is working quite good where I am also facing this warning.

提交回复
热议问题