setting android:saveEnabled="false" for the RadioButton made this problem go away.
On May 11, 6:12 pm, abhi <rkabhi1...@gmail.com> wrote: > Hello, I am trying to set a RadioButton as checked/not checked through > code. It is working the first time I set it, but the second time, the > code does not set the button. Here is the relevant part of my code. I > have commented on the problematic part. > > private boolean val; > �...@override > protected void onCreate(Bundle savedInstanceState) { > > // after orientation change, get the value > final Object obj = getLastNonConfigurationInstance(); > if (null != obj) { > val = (boolean)obj; > } > init(); > > } > > private void init() { > RadioButton rb = (RadioButton) findViewById(R.id.rb); > //This is working the first time init() called. But second time its > called on configuration change, not working. > rb.setChecked(val); > } > @Override > public Object onRetainNonConfigurationInstance() { > return val; > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en