English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.CheckBox

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.widget.TextView
android.widget.Button
android.widget.CompoundButton
android.widget.CheckBox

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);
         }
     }
 }
 

XML attributes

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

Summary

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

Public Constructors

          CheckBox(Context context)
          CheckBox(Context context, AttributeSet attrs, Map inflateParams)
          CheckBox(Context context, AttributeSet attrs, Map inflateParams, int defStyle)
Methods inherited from class android.widget.CompoundButton
Methods inherited from class android.widget.TextView