Difference between OnClick() event and OnClickListener?

后端 未结 16 2394
醉话见心
醉话见心 2020-12-01 12:13

I\'m always using onclick() event in most of my projects. But, I read about OnClickListener(). Can anyone tell what\'s the difference between these

16条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 12:58

    I'm not sure the question is clear. View.OnClickListener is an interface, which defines the onClick(View) method. If you have a class which intends to listen for clicks, you should both implement the interface (if not already extending a class that does), and implement this method too. You have to use both; they're not somehow alternatives.

提交回复
热议问题