79599959

Date: 2025-04-30 09:11:19
Score: 2
Natty:
Report link

I've analyzed your Android code, and I see the issue with your variables resetting when radio buttons are selected. Let me explain the problem and solution.

The Problem

The issue occurs because you're initializing idPregunta and idRespuesta as regular variables inside your composable function. Since composable functions can be recomposed (re-executed) whenever state changes - like when selecting a radio button - these variables get reset to their initial values each time.

// These variables are being reinitialized on every recomposition
var idPregunta = 1
var idRespuesta = 1

The Solution

As you correctly identified in your edit, you need to use remember { mutableStateOf() } for these variables to preserve their values across recompositions. This ensures your ID values persist when the UI updates.

Reasons:
  • Blacklisted phrase (2): Pregunta
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Hossein S