0

I have used android CheckBox and current state is checked when I rotate the screen checked state is changed to unchecked.

I have attached the code:

 CheckBox check = new CheckBox(this);
 check.Text = "CheckBox";
 linearLayout.AddView(check);

Please find the screen shot: Portrait:

enter image description here

Landscape:

enter image description here

How to restrict this? Thanks in advance.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
yoganathan k
  • 213
  • 4
  • 16
  • https://stackoverflow.com/questions/151777/saving-android-activity-state-using-save-instance-state – ADM May 07 '18 at 14:25

1 Answers1

0

Answer copied from below link

Android CheckBox -- Restoring State After Screen Rotation

"Solution were to disable 'restoring instance state':

<RadioButton
...
android:saveEnabled="false" />

"

Since you're creating the checkmark programatically, you may be able to do:

check.saveEnabled = false;
Marker
  • 560
  • 4
  • 20