Most visited

Recently visited

Added in API level 1

RadioButton

public class RadioButton
extends CompoundButton

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.Button
         ↳ android.widget.CompoundButton
           ↳ android.widget.RadioButton
Known Direct Subclasses


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

Inherited XML attributes

From class android.widget.CompoundButton
From class android.widget.TextView
From class android.view.View

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

RadioButton(Context context)
RadioButton(Context context, AttributeSet attrs)
RadioButton(Context context, AttributeSet attrs, int defStyleAttr)
RadioButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

CharSequence getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

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.

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.widget.Checkable
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

RadioButton

Added in API level 1
RadioButton (Context context)

Parameters
context Context

RadioButton

Added in API level 1
RadioButton (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

RadioButton

Added in API level 1
RadioButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

RadioButton

Added in API level 21
RadioButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

getAccessibilityClassName

Added in API level 23
CharSequence getAccessibilityClassName ()

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

toggle

Added in API level 1
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.

Hooray!