Code example for RadioButton

Methods: getId, isChecked

0
 
  @Override 
  public void addView(final View child, final int index, final ViewGroup.LayoutParams params) {
    if (child instanceof RadioButton) {
      final RadioButton button = (RadioButton) child;
      if (button.isChecked()) {
        mProtectFromCheckedChange = true;
        if (mCheckedId != -1) {
          setCheckedStateForView(mCheckedId, false);
        } 
        mProtectFromCheckedChange = false;
        setCheckedId(button.getId());
      } 
    } 
 
    super.addView(child, index, params);
  } 
 
  /** 
   * <p> 
   * Sets the selection to the radio button whose identifier is passed in