Difference between OnClick() event and OnClickListener?

后端 未结 16 2430
醉话见心
醉话见心 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 13:03

    The main diffrence between onclick() and setOnClicklisner() is discribed as follow:

    1. onclick()
      Is a attribute in xml. when a button is clicked onclick method is called suppose you have three button in layout you can add only one function of onclick() and when any of one button will clicked onclick() will called

    2. setOnClicklistner()
      Suppose you have three button in layout you want to perform different action from them. Then you should use setonClicklistner() method on each of button to give different method for them

提交回复
热议问题