Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

RadioButton

extends CompoundButton
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.Button
         ↳ android.widget.CompoundButton
           ↳ android.widget.RadioButton

Class Overview

A radio button is a two-states button that can be either checked or unchecked. When the radio button is unchecked, the user can press or click it to check it. However, contrary to a CheckBox , a radio button cannot be unchecked by the user once checked.

Radio buttons are normally used together in a RadioGroup . When several radio buttons live inside a radio group, checking one radio button unchecks all the others.

See the Radio Buttons guide.

XML attributes

See CompoundButton Attributes , Button Attributes , TextView Attributes , View Attributes

Summary

[Expand]
Inherited XML Attributes
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
RadioButton ( Context context)
RadioButton ( Context context, AttributeSet attrs)
RadioButton ( Context context, AttributeSet attrs, int defStyle)
Public Methods
void onInitializeAccessibilityEvent ( AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo ( AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
void toggle ()
Change the checked state of the view to the inverse of its current state

If the radio button is already checked, this method will not toggle the radio button.

[Expand]
Inherited Methods
From class android.widget.CompoundButton
From class android.widget.Button
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.view.accessibility.AccessibilityEventSource
From interface android.widget.Checkable

Public Constructors

public RadioButton ( Context context)

Added in API level 1

public RadioButton ( Context context, AttributeSet attrs)

Added in API level 1

public RadioButton ( Context context, AttributeSet attrs, int defStyle)

Added in API level 1

Public Methods

public void onInitializeAccessibilityEvent ( AccessibilityEvent event)

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

          public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     super.onInitializeAccessibilityEvent(event);
     event.setPassword(true);
 }
         

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo ( AccessibilityNodeInfo info)

Parameters
info The instance to initialize.

public void toggle ()

Added in API level 1

Change the checked state of the view to the inverse of its current state

If the radio button is already checked, this method will not toggle the radio button.