Skip to content
Advertisement

How to initialize a Radio Group/Button on a file that does not correspond to the xml file

I have about 25 buttons, a RadioGroup with 4 radio buttons all in one layout. Which change what the buttons do. To reduce the number of lines and make the code more efficient I am trying to initialize the radiogroup and radioButtons on a different Kotlin file that is not the Main Activity (inside onCreate function).

Is there a way that I can assign the radio buttons/group on a different file for example: rdButtons.kt ?

Advertisement

Answer

I’d recommend to you make them all in one xml file. You can also use include tag in xml if you want to reuse layouts

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement