Toggle Button to turn layer on/off

Discussion created by JFA0427 on Jun 17, 2013
Latest reply on Aug 6, 2019 by wsimiyu_EsriEA
Does anyone have any code they can post showing how they used a toggle button in a alertdialog to turn a featurelayer on and off in the map view?

I've tried doing this and I can get images, like the esri logo, to turn on and off in the mapview, but as soon as i use fLayer.setVisible(true); my app will crash. Same goes for when I use radio buttons and check boxes.

Any help would be great.