Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – How to initialize a Radio Group/Button on a file that does not correspond to the xml file

Posted on November 11, 2022 By

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

Problem :

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 ?

Comments

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(

READ  [FIXED] java - DatepickerDialog doesnt add Date in Textview
Powered by Inline Related Posts
Android Tags:android, android-studio, java, kotlin

Post navigation

Previous Post: [FIXED] java – is permission needed when choosing image from gallery on android?
Next Post: [FIXED] Android Java: How to get component in a custom view? (Trying to access components via findByViewId and get null)

Related Posts

[FIXED] java – How can i change the textview of a layout in different activity on click of customInfoWindow in main activity Android
[FIXED] android – ViewModel not detaching observer and causing nullpointerexceptions Android
[FIXED] java – Android Gradle Sync failed: Could not resolve all artifacts for configuration ‘:classpath’ Android
[FIXED] android – Button Layout changes on different devices Android
[FIXED] android – Why is Facebook’s Unity SDK Not Logging Events To Analytics? Android
[FIXED] android – Why line_solid does not appear? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme