FileDocCategorySizeDatePackage
RadioButton.javaAPI DocAndroid 5.1 API3149Thu Mar 12 22:22:10 GMT 2015android.widget

RadioButton

public class RadioButton extends CompoundButton

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 {@link android.widget.CheckBox}, a radio button cannot be unchecked by the user once checked.

Radio buttons are normally used together in a {@link android.widget.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 {@link android.R.styleable#CompoundButton CompoundButton Attributes}, {@link android.R.styleable#Button Button Attributes}, {@link android.R.styleable#TextView TextView Attributes}, {@link android.R.styleable#View View Attributes}

Fields Summary
Constructors Summary
public RadioButton(android.content.Context context)

        this(context, null);
    
public RadioButton(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, com.android.internal.R.attr.radioButtonStyle);
    
public RadioButton(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public RadioButton(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
    
Methods Summary
public voidonInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        super.onInitializeAccessibilityEvent(event);
        event.setClassName(RadioButton.class.getName());
    
public voidonInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)

        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(RadioButton.class.getName());
    
public voidtoggle()
{@inheritDoc}

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

        // we override to prevent toggle when the radio is already
        // checked (as opposed to check boxes widgets)
        if (!isChecked()) {
            super.toggle();
        }