Handle orientation from Portrait to Landscape mode for Checkbox
<p>I am using the Checkbox on a layout xml .</p>

<pre><code>&lt;CheckBox android:id="@+id/chkbox" 
android:checked="false" android:button="@drawable/ic_uncheck_img"&gt;
</code></pre>

<p>The Checkbox is by default set to "false" &amp; a image is added for unchecked button.</p>

<pre><code>private CheckBox mCheck= null;

public void onCreate(Bundle savedInstanceState) {

mCheck= (CheckBox) findViewById(R.id.chkbox);
        mCheck.setChecked(false);
        mCheck.setButtonDrawable(R.drawable.ic_uncheck_img);


}

public void onClick(View view) {

            if (view.getId() == R.id.chkbox) {
                if (mCheck.isChecked())
                    mCheck.setButtonDrawable(R.drawable.ic_check_img);
                else
                    mCheck.setButtonDrawable(R.drawable.ic_uncheck_img);
}
</code></pre>

<p>Within the onClick() , when the user clicks on the Checkbox , the image changes from uncheck to check . User does that on the portrait mode.</p>

<p>When the user changes orientation to the landscape mode of the device, the check disappears &amp; the uncheck image is displayed . The state of the Checkbox is not maintained when the orientation changes from portrait to landscape.</p>

<p>Kindly provide your inputs on how to maintain the state of the Checkbox even if the orientation changes.</p>

<p>Thanks in advance.</p>

<p>Warm Regards,</p>

<p>CB</p>
