title: Android checking radio button in code makes it stay checked in a radiogroup
body: <p>I have a dynamically added radio buttons in a <code>RadioGroup</code>. And I have to check one of them in code based on some data.</p>
  
  <p>Now, the issue is after the radio buttons are shown and the user checks on another radio button in the same group, the previously selected radio is still checked ... resulting in two checked <code>RadioButtons</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/hSQze.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hSQze.png" alt="Radio buttons with one of them that can&#39;t be unchecked"></a></p>
  
  <p>This is how I am rendering the buttons in Kotlin:</p>
  
  <pre><code>val rg = RadioGroup(this).apply { orientation = RadioGroup.HORIZONTAL }
  choices.values.forEach { c -&gt;
      rg.addView(RadioButton(this).apply {
          tag = someTag
          text = c
          isChecked = answer.equals(c) // condition
      })
  }
  </code></pre>
  
  <p>The strange thing is it all works fine if no <code>RadioButton</code> is checked programmatically.</p>