title: How do I get the selected radio button when the radio group is inflated programmatically.
body: <p>I have a layout that is built dynamically from a database. There are several sections, One of the pieces is a series of radio groups with custom text on each radio button that is read from the database. </p>
  
  <p>My code is properly inflating the layout, adding the correct number of radio buttons and adding the correct text to them.</p>
  
  <p>What I can't figure out is how to get the value of the checked radio button when it is a child of a table row. I am not using an on item selected because I need to wait until the user is sure all the answers are filled in before getting the results. So I have a separate button with an onClick that is going to read the data and store it in the database. </p>
  
  <p>Here is the area in my main XML file
      
          
          <br>
      <br>
  Here is the individual row XML
      
      </p>
  
  <pre><code>    &lt;RadioGroup
          android:id="@+id/radioGroup1"
          android:orientation="horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"&gt;
    &lt;/RadioGroup&gt;
  
  &lt;/TableRow&gt;
  </code></pre>
  
  <p>Here is where I am trying to read the values of the selected radio button</p>
  
  <pre><code>table = (TableLayout) findViewById(R.id.TableLayout03);
  for( int ii = 0; ii &lt; nRecs3; ii++ ){   
  TableRow row1= (TableRow)table.getChildAt(ii);
  Log.i("radio button " , " index of row is " + String.valueOf(row1));
  View child = table.getChildAt(ii);
  int idx = row1.indexOfChild(child);
  Log.i("radio button " , " index of child is " + String.valueOf(idx));
  RadioGroup radio = (RadioGroup)child;
  Log.i("radio button " , " checked button is " + String.valueOf(radio.getCheckedRadioButtonId()));
              }
  </code></pre>
  
  <p>but it's crashing before it gets to the first log statement. I've tried all sorts of variations on getting the value of the child of the child row but nothing is working. </p>