Where do you set this? On Wednesday, May 12, 2010 at 6:56:50 PM UTC+2, baka wrote: > > 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-d...@googlegroups.com > <javascript:> > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com <javascript:> > > 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-d...@googlegroups.com > <javascript:> > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com <javascript:> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/2869e6dc-4ddd-4f31-a3c5-b416f69fcba8%40googlegroups.com.