Difference between OnClick() event and OnClickListener?

后端 未结 16 2424
醉话见心
醉话见心 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:53

    everyone has mentioned about OnClickListener listner which one always used. i want to add one more point android:onClick works as method and it's doesn't need to be reference so it's useful when you have to add button after some task executed so you cant't referenced it for OnClickListener.

    For an example when we create viewpager with only layout (no fragments) if you put an button in any layout it insialized only when layout visible so you can't use method findViewById for Button in that case android:onClick becomed useful just put that method in activity!!

提交回复
热议问题