Class RelativeRadioGroup

All Implemented Interfaces:
Drawable.Callback, ViewManager, ViewParent

public class RelativeRadioGroup extends RelativeLayout

This class is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group.

Initially, all of the radio buttons are unchecked. While it is not possible to uncheck a particular radio button, the radio group can be cleared to remove the checked state.

See Also:
  • Constructor Details

    • RelativeRadioGroup

      public RelativeRadioGroup(Context context)
  • Method Details

    • onViewAdded

      protected void onViewAdded(View child)
      Description copied from class: ViewGroup
      Called when a new child is added to this ViewGroup. Overrides should always call super.onViewAdded.
      Overrides:
      onViewAdded in class ViewGroup
      Parameters:
      child - the added child view
    • onViewRemoved

      protected void onViewRemoved(View child)
      Description copied from class: ViewGroup
      Called when a child view is removed from this ViewGroup. Overrides should always call super.onViewRemoved.
      Overrides:
      onViewRemoved in class ViewGroup
      Parameters:
      child - the removed child view
    • check

      public void check(int id)

      Sets the selection to the radio button whose identifier is passed in parameter. Using View.NO_ID as the selection identifier clears the selection; such an operation is equivalent to invoking clearCheck().

      Parameters:
      id - the unique id of the radio button to select in this group
      See Also:
    • getCheckedId

      public final int getCheckedId()

      Returns the identifier of the selected radio button in this group. Upon empty selection, the returned value is View.NO_ID.

      Returns:
      the unique id of the selected radio button in this group
      See Also:
    • clearCheck

      public final void clearCheck()

      Clears the selection. When the selection is cleared, no radio button in this group is selected and getCheckedId() returns View.NO_ID.

      See Also:
    • setOnCheckedChangeListener

      public void setOnCheckedChangeListener(@Nullable RelativeRadioGroup.OnCheckedChangeListener listener)

      Register a callback to be invoked when the checked radio button changes in this group.

      Parameters:
      listener - the callback to call on checked state change
    • generateDefaultLayoutParams

      @Nonnull protected ViewGroup.LayoutParams generateDefaultLayoutParams()
      Description copied from class: ViewGroup
      Returns a set of default layout parameters. These parameters are requested when the View passed to ViewGroup.addView(View) has no layout parameters already set. If null is returned, an exception is thrown from addView.
      Overrides:
      generateDefaultLayoutParams in class RelativeLayout
      Returns:
      a set of default layout parameters