Ayuda con interruptor (switch)

Hola,
Quisiera la ayuda de ustedes.
Tengo problemas para comprender el funcionamiento del interruptor (switch).
Necesito utilizar varios para una misma función, por ejemplo:

Al presionar botón para calcular hará una multiplicación de A * B = C.

Al encender interruptor aparecerá una pantalla donde existan 3 interruptores mas, al apagar se esconde y/o borra lo anterior. (ya resuelto)

Los 3 interruptores que aparecerán (secundarios), les daré nombres de leve (D), moderado (E) y severo (F). Cada interruptor encendido tendrá un valor distinto, los cuales tendrán que multiplicarse por valor de un campo de texto (G) y sumarse a la multiplicación inicial de A * B = C

Al encender cualquier interruptor leve se apagará en automático los de moderado y severo, y así cada uno respectivamente (también resuelto)

El punto a cuestionar es ¿Cómo hago para que al encender el interruptor leve (D), se multiplique su valor con el campo de texto (G)? y así cada interruptor encendido y el resultado se plasme en una etiqueta (H).

Hello,
I would like your help.

I'm having trouble understanding how a switch works.
I need to use several switches for the same function, for example:

Pressing the button to calculate will multiply A * B = C.

When you turn the switch on, a screen will appear showing three more switches; when you turn it off, it will hide and/or delete the previous one. (already solved)

I will name the three switches that appear (secondary switches): mild (D), moderate (E), and severe (S). Each switched on switch will have a different value, which will have to be multiplied by the value in a text field (G) and added to the initial multiplication of A * B = C.

Turning on any mild switch will automatically turn off the moderate and severe switches, and so on for each switch. (also solved)

The question is, how do I get the mild switch (D) to multiply its value by the text field (G) when I turn on the switch? So that each switched on switch is multiplied, and the result is printed on a label (H).

(Traductor google)

Your collection of three switches could be replaced by a single List Picker, ListView, or Spinner.

The Elements would be the words mild,moderate,severe.

You could keep a table mapping those words into their corresponding multiplier, and use the lookup in pairs list block to look up the multiplier corresponding to the user's Selection.

1 Like

How can I do the sum with the spinners? When selecting a value (Mild, Moderate and Severe), make that value add up or multiply with an X value?

The solution that @ABG has proposed you is much more elegant, but if I have correctly understood your needs, you might also try a simple one like the following ?
The computation procedure in my example is almost empty, it has to be customized as per your formula, but it's just to give you the idea. The value of the global variable Multiplier in my example is just 1,2,3, but you shall put your values, instead, of course.

EDIT: not tested.... :grin: :grin: :grin:

Muchas gracias. Iniciaré a ponerlo a prueba a ver si me sale bien