The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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.preference; |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
| 21 | |
| 22 | /** |
| 23 | * Used to group {@link Preference} objects |
| 24 | * and provide a disabled title above the group. |
Scott Main | cdd0c59 | 2012-07-26 17:03:51 -0700 | [diff] [blame] | 25 | * |
| 26 | * <div class="special reference"> |
| 27 | * <h3>Developer Guides</h3> |
| 28 | * <p>For information about building a settings UI with Preferences, |
| 29 | * read the <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a> |
| 30 | * guide.</p> |
| 31 | * </div> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | */ |
| 33 | public class PreferenceCategory extends PreferenceGroup { |
| 34 | private static final String TAG = "PreferenceCategory"; |
Alan Viverette | 617feb9 | 2013-09-09 18:09:13 -0700 | [diff] [blame] | 35 | |
| 36 | public PreferenceCategory( |
| 37 | Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 38 | super(context, attrs, defStyleAttr, defStyleRes); |
| 39 | } |
| 40 | |
| 41 | public PreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) { |
| 42 | this(context, attrs, defStyleAttr, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | public PreferenceCategory(Context context, AttributeSet attrs) { |
| 46 | this(context, attrs, com.android.internal.R.attr.preferenceCategoryStyle); |
| 47 | } |
| 48 | |
| 49 | public PreferenceCategory(Context context) { |
| 50 | this(context, null); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | protected boolean onPrepareAddPreference(Preference preference) { |
| 55 | if (preference instanceof PreferenceCategory) { |
| 56 | throw new IllegalArgumentException( |
| 57 | "Cannot add a " + TAG + " directly to a " + TAG); |
| 58 | } |
| 59 | |
| 60 | return super.onPrepareAddPreference(preference); |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public boolean isEnabled() { |
| 65 | return false; |
| 66 | } |
| 67 | |
Alan Viverette | 02f5680 | 2013-08-19 16:32:56 -0700 | [diff] [blame] | 68 | @Override |
| 69 | public boolean shouldDisableDependents() { |
| 70 | return !super.isEnabled(); |
| 71 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | } |