English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.RadioGroup

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.LinearLayout
android.widget.RadioGroup

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.

Intially, 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.

The selection is identified by the unique id of the radio button as defined in the XML layout file.

XML Attributes

See RadioGroup Attributes, LinearLayout Attributes, ViewGroup Attributes, View Attributes

Also see LinearLayout.LayoutParams for layout attributes.

Nested Classes
RadioGroup.LayoutParams

This set of layout parameters defaults the width and the height of the children to WRAP_CONTENT when they are not specified in the XML file. 

RadioGroup.OnCheckedChangeListener

Interface definition for a callback to be invoked when the checked radio button changed in this group. 

See Also

Summary

XML Attributes inherited from class android.widget.LinearLayout
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.widget.LinearLayout
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View
Fields inherited from class android.widget.LinearLayout
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

          RadioGroup(Context context)
          RadioGroup(Context context, AttributeSet attrs, Map inflateParams)

Public Methods

        void  check(int id)

Sets the selection to the radio button whose identifier is passed in parameter.

        void  clearCheck()

Clears the selection.

        LayoutParams  generateLayoutParams(AttributeSet attrs)
        int  getCheckedRadioButtonId()

Returns the identifier of the selected radio button in this group.

        void  setOnCheckedChangeListener(OnCheckedChangeListener listener)

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

        void  setOnHierarchyChangeListener(OnHierarchyChangeListener listener)
Register a callback to be invoked when a child is added to or removed from this view.

Protected Methods

        boolean  checkLayoutParams(LayoutParams p)
        void  onFinishInflate()
Finalize inflating a view from XML.
Methods inherited from class android.widget.LinearLayout
Methods inherited from class android.view.ViewGroup