The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.widget; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
Svetoslav Ganov | 7650259 | 2011-07-29 10:44:59 -0700 | [diff] [blame] | 21 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav Ganov | 8a78fd4 | 2012-01-17 14:36:46 -0800 | [diff] [blame] | 22 | import android.view.accessibility.AccessibilityNodeInfo; |
Svetoslav Ganov | 7650259 | 2011-07-29 10:44:59 -0700 | [diff] [blame] | 23 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * <p> |
| 27 | * A checkbox is a specific type of two-states button that can be either |
| 28 | * checked or unchecked. A example usage of a checkbox inside your activity |
| 29 | * would be the following: |
| 30 | * </p> |
| 31 | * |
| 32 | * <pre class="prettyprint"> |
| 33 | * public class MyActivity extends Activity { |
| 34 | * protected void onCreate(Bundle icicle) { |
| 35 | * super.onCreate(icicle); |
| 36 | * |
| 37 | * setContentView(R.layout.content_layout_id); |
| 38 | * |
| 39 | * final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id); |
| 40 | * if (checkBox.isChecked()) { |
| 41 | * checkBox.setChecked(false); |
| 42 | * } |
| 43 | * } |
| 44 | * } |
| 45 | * </pre> |
Scott Main | 41ec653 | 2010-08-19 16:57:07 -0700 | [diff] [blame] | 46 | * |
Scott Main | 4c359b7 | 2012-07-24 15:51:27 -0700 | [diff] [blame] | 47 | * <p>See the <a href="{@docRoot}guide/topics/ui/controls/checkbox.html">Checkboxes</a> |
| 48 | * guide.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | * |
| 50 | * <p><strong>XML attributes</strong></p> |
| 51 | * <p> |
| 52 | * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, |
| 53 | * {@link android.R.styleable#Button Button Attributes}, |
| 54 | * {@link android.R.styleable#TextView TextView Attributes}, |
| 55 | * {@link android.R.styleable#View View Attributes} |
| 56 | * </p> |
| 57 | */ |
Philip Milne | ab104ba | 2013-04-19 03:53:38 +0000 | [diff] [blame] | 58 | public class CheckBox extends CompoundButton { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | public CheckBox(Context context) { |
| 60 | this(context, null); |
| 61 | } |
| 62 | |
| 63 | public CheckBox(Context context, AttributeSet attrs) { |
| 64 | this(context, attrs, com.android.internal.R.attr.checkboxStyle); |
| 65 | } |
| 66 | |
| 67 | public CheckBox(Context context, AttributeSet attrs, int defStyle) { |
| 68 | super(context, attrs, defStyle); |
| 69 | } |
Svetoslav Ganov | 7650259 | 2011-07-29 10:44:59 -0700 | [diff] [blame] | 70 | |
| 71 | @Override |
Svetoslav Ganov | 8a78fd4 | 2012-01-17 14:36:46 -0800 | [diff] [blame] | 72 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 73 | super.onInitializeAccessibilityEvent(event); |
| 74 | event.setClassName(CheckBox.class.getName()); |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
| 79 | super.onInitializeAccessibilityNodeInfo(info); |
| 80 | info.setClassName(CheckBox.class.getName()); |
| 81 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | } |