Most visited

Recently visited

Added in API level 1

CheckBox

public class CheckBox
extends CompoundButton

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


复选框是一种特定类型的双态按钮,可以选中或不选中。 活动内部复选框的示例用法如下:

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

请参阅 Checkboxes指南。

XML属性

CompoundButton AttributesButton AttributesTextView AttributesView 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

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

Public methods

CharSequence getAccessibilityClassName()

返回此对象的类名称以用于辅助功能。

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

CheckBox

Added in API level 1
CheckBox (Context context)

Parameters
context Context

CheckBox

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

Parameters
context Context
attrs AttributeSet

CheckBox

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

Parameters
context Context
attrs AttributeSet
defStyleAttr int

CheckBox

Added in API level 21
CheckBox (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 ()

返回此对象的类名称以用于辅助功能。 如果子类正在实现的东西应该被视为一个全新的视图类,当它被可访问性使用时,子类只应该覆盖这个子类,与它所源自的类无关。 这用于填写AccessibilityNodeInfo.setClassName

Returns
CharSequence

Hooray!