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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | /** |
| 23 | * <p> |
| 24 | * A checkbox is a specific type of two-states button that can be either |
| 25 | * checked or unchecked. A example usage of a checkbox inside your activity |
| 26 | * would be the following: |
| 27 | * </p> |
| 28 | * |
| 29 | * <pre class="prettyprint"> |
| 30 | * public class MyActivity extends Activity { |
| 31 | * protected void onCreate(Bundle icicle) { |
| 32 | * super.onCreate(icicle); |
| 33 | * |
| 34 | * setContentView(R.layout.content_layout_id); |
| 35 | * |
| 36 | * final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id); |
| 37 | * if (checkBox.isChecked()) { |
| 38 | * checkBox.setChecked(false); |
| 39 | * } |
| 40 | * } |
| 41 | * } |
| 42 | * </pre> |
Scott Main | 41ec653 | 2010-08-19 16:57:07 -0700 | [diff] [blame] | 43 | * |
Scott Main | 4c359b7 | 2012-07-24 15:51:27 -0700 | [diff] [blame] | 44 | * <p>See the <a href="{@docRoot}guide/topics/ui/controls/checkbox.html">Checkboxes</a> |
| 45 | * guide.</p> |
Aurimas Liutikas | 99441c5 | 2016-10-11 16:48:32 -0700 | [diff] [blame] | 46 | * |
| 47 | * <p><strong>XML attributes</strong></p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | * <p> |
Aurimas Liutikas | 99441c5 | 2016-10-11 16:48:32 -0700 | [diff] [blame] | 49 | * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, |
| 50 | * {@link android.R.styleable#Button Button Attributes}, |
| 51 | * {@link android.R.styleable#TextView TextView Attributes}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | * {@link android.R.styleable#View View Attributes} |
| 53 | * </p> |
| 54 | */ |
Philip Milne | ab104ba | 2013-04-19 03:53:38 +0000 | [diff] [blame] | 55 | public class CheckBox extends CompoundButton { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | public CheckBox(Context context) { |
| 57 | this(context, null); |
| 58 | } |
Aurimas Liutikas | 99441c5 | 2016-10-11 16:48:32 -0700 | [diff] [blame] | 59 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | public CheckBox(Context context, AttributeSet attrs) { |
| 61 | this(context, attrs, com.android.internal.R.attr.checkboxStyle); |
| 62 | } |
| 63 | |
Alan Viverette | 617feb9 | 2013-09-09 18:09:13 -0700 | [diff] [blame] | 64 | public CheckBox(Context context, AttributeSet attrs, int defStyleAttr) { |
| 65 | this(context, attrs, defStyleAttr, 0); |
| 66 | } |
| 67 | |
| 68 | public CheckBox(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 69 | super(context, attrs, defStyleAttr, defStyleRes); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | } |
Svetoslav Ganov | 7650259 | 2011-07-29 10:44:59 -0700 | [diff] [blame] | 71 | |
| 72 | @Override |
Dianne Hackborn | a7bb6fb | 2015-02-03 18:13:40 -0800 | [diff] [blame] | 73 | public CharSequence getAccessibilityClassName() { |
| 74 | return CheckBox.class.getName(); |
Svetoslav Ganov | 8a78fd4 | 2012-01-17 14:36:46 -0800 | [diff] [blame] | 75 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | } |