https://kotlinlang.org logo
n

Nat Strangerweather

09/24/2020, 4:46 PM
Is there a tutorial for custom radio buttons? I got a kind reply here but I have not managed to understand how it is supposed to work. 😥
a

Anna-Chiara Bellini [G]

09/24/2020, 5:21 PM
You don't need to do anything to manage the "deselect something when something else is selected", that's the mental shift you need to make in declarative frameworks. All you need to do is make sure that, to each BoxCards, you pass a "selected" value that is true when you want it selected, false otherwise. If you see the code snippet in the answer to your previous post, the only remembered state is the index of the radiobutton that you want selected. then you pass a parameter
selected
(True or False) to each invocation of the BoxCards composable. All the code is going to be re-executed as needed, so you don't have to worry about state transitions. Hope this makes sense?
n

Nat Strangerweather

09/24/2020, 5:28 PM
@Anna-Chiara Bellini [G] Thank you for the explanation, yes, it does make sense! 👍🙂
a

Anna-Chiara Bellini [G]

09/24/2020, 5:28 PM
Glad to hear that 🙂 Feel free to ask more questions if you get stuck!
👍 1
4 Views