FileDocCategorySizeDatePackage
CheckBox.javaAPI DocAndroid 5.1 API2831Thu Mar 12 22:22:10 GMT 2015android.widget

CheckBox

public class CheckBox extends CompoundButton

A checkbox is a specific type of two-states button that can be either checked or unchecked. A example usage of a checkbox inside your activity would be the following:

public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);

setContentView(R.layout.content_layout_id);

final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
if (checkBox.isChecked()) {
checkBox.setChecked(false);
}
}
}

See the Checkboxes 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 CheckBox(android.content.Context context)

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

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

        this(context, attrs, defStyleAttr, 0);
    
public CheckBox(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(CheckBox.class.getName());
    
public voidonInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)

        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(CheckBox.class.getName());