Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid UI shows RadioButton as selected, although it is not
    primarykey
    data
    text
    <p>When my UI is recreated on orientation change, I use <code>super.onCreate(savedInstanceState)</code> and <code>getLastNonConfigurationInstance()</code> to access custom data I stored to fill the dynamic parts of my layout.</p> <p>I have a RadioGroup which has two RadioButtons and is already defined in the XML file. The XML automatically makes the first one selected.</p> <p>When an orientation change happens and the SECOND RadioButton is selected, everything seems to work fine; the second RadioButton is still selected in the UI.</p> <p>But <code>RadioGroup.getCheckedRadioButtonId()</code> says the first RadioButton is selected. And I actually WANT the first one to be selected. But nothing changes when I call <code>rb1.setChecked(true)</code> - second one still shown as selected, and still the RadioGroup tells me the first one is selected (now it would make sense, but it's not shown).</p> <p>This is REALLY strange behavior, does anyone have tips?</p> <p>(edit) Parts of my code:</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.itemselected); (...) radioGroupServingType = (RadioGroup) findViewById(R.id.radioGroupServingType); (...) RadioButton radioOwnServing = (RadioButton) findViewById(R.id.radioOwnServing); RadioButton radioUseServing = (RadioButton) findViewById(R.id.radioUseServing); radioOwnServing.setOnClickListener(this); radioUseServing.setOnClickListener(this); //FIXME WTF Log.d("", radioOwnServing.isChecked()+"/"+radioUseServing.isChecked()+" own/use checked"); radioOwnServing.setChecked(true); Log.d("", radioOwnServing.isChecked()+"/"+radioUseServing.isChecked()+" own/use checked"); </code></pre> <p>If I select radioUseServing in the UI and change the orientation, the log says <code>true/false own/use checked</code> both times - although radioUseServing is shown as selected in the UI.</p> <p>By the way, logcat also outputs </p> <pre><code>W/asset(4040): deep redirect failure from 0x0103003e =&gt; 0x02060007, defStyleAttr=0x0101007e, defStyleRes=0x0103001a, style=0x00000000 </code></pre> <p>when changing the orientation, sometimes multiple times. I haven't found anything with google on what that means.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload