Programmatically Change a Switch

edited May 2015 in UC Berkeley CS160

So I'm having a weird issue, similar to my radio button issue, in that I can't correctly set the value of a switch to 1 programmatically. I set data.value = 1 and I run the onValueChanged method as well and that doesn't work. When I do the opposite (set it to 0 then call onValueChanged) the switch gets reset as I would like. What's weird is, I have the switch there to hide and show content. When it's on, the content is displayed, when it's off the content is hidden. When I view the screen, the switch is in the off position but the content is displayed. However, the switch isn't backwards. If I click the switch to on, the content remains shown, and when I toggle it back to off it gets hidden as expected. It just needs a click to get it back to the right state. Does anyone know why the switch might be shown in the wrong position?

Sign In or Register to comment.