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
17package android.preference;
18
19import java.util.Map;
20
21import android.content.Context;
22import android.util.AttributeSet;
23
24/**
25 * Used to group {@link Preference} objects
26 * and provide a disabled title above the group.
27 *
28 * <div class="special reference">
29 * <h3>Developer Guides</h3>
30 * <p>For information about building a settings UI with Preferences,
31 * read the <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>
32 * guide.</p>
33 * </div>
34 */
35public class PreferenceCategory extends PreferenceGroup {
36    private static final String TAG = "PreferenceCategory";
37
38    public PreferenceCategory(Context context, AttributeSet attrs, int defStyle) {
39        super(context, attrs, defStyle);
40    }
41
42    public PreferenceCategory(Context context, AttributeSet attrs) {
43        this(context, attrs, com.android.internal.R.attr.preferenceCategoryStyle);
44    }
45
46    public PreferenceCategory(Context context) {
47        this(context, null);
48    }
49
50    @Override
51    protected boolean onPrepareAddPreference(Preference preference) {
52        if (preference instanceof PreferenceCategory) {
53            throw new IllegalArgumentException(
54                    "Cannot add a " + TAG + " directly to a " + TAG);
55        }
56
57        return super.onPrepareAddPreference(preference);
58    }
59
60    @Override
61    public boolean isEnabled() {
62        return false;
63    }
64
65}
66