blob: 253481baf1d1af11851cff04859ff2c686a5cdb0 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.preference;
18
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.content.Context;
20import android.util.AttributeSet;
21
22/**
23 * Used to group {@link Preference} objects
24 * and provide a disabled title above the group.
Scott Maincdd0c592012-07-26 17:03:51 -070025 *
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 Project9066cfe2009-03-03 19:31:44 -080032 */
33public class PreferenceCategory extends PreferenceGroup {
34 private static final String TAG = "PreferenceCategory";
Alan Viverette617feb92013-09-09 18:09:13 -070035
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 Project9066cfe2009-03-03 19:31:44 -080043 }
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 Viverette02f56802013-08-19 16:32:56 -070068 @Override
69 public boolean shouldDisableDependents() {
70 return !super.isEnabled();
71 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072}