In a new app that I’m trying to create I have 3 separate layouts to switch between, and each have their own buttons on them.
Is it necessary to setOnClickListener(listener) every time that I change to that view or is there a manner of permanently adding a listener?
Thanks!
First, a better practice is to create 3 activities each having its own layout and then switch between them. But if you need your application to stay this way, then yes, you will need to initialize your
onClickListenersevery time you inflate new layouts. Hope this helps.