Solution 1 :
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
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 ?
Comment posted by Meet Patel
I realized that the question was not worded properly all the elements are in fact on the same xml file but I want the radio Buttons to be called on a different kotlin file and not the main activity.
Comment posted by developer.android.com/training/custom-views/create-view
Ok, got it. Of course you can. You can create a custom view(