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

Time:06-13

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 ?

CodePudding user response:

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

  • Related