PreferenceCategory.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
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 */
28public class PreferenceCategory extends PreferenceGroup {
29    private static final String TAG = "PreferenceCategory";
30
31    public PreferenceCategory(Context context, AttributeSet attrs, int defStyle) {
32        super(context, attrs, defStyle);
33    }
34
35    public PreferenceCategory(Context context, AttributeSet attrs) {
36        this(context, attrs, com.android.internal.R.attr.preferenceCategoryStyle);
37    }
38
39    public PreferenceCategory(Context context) {
40        this(context, null);
41    }
42
43    @Override
44    protected boolean onPrepareAddPreference(Preference preference) {
45        if (preference instanceof PreferenceCategory) {
46            throw new IllegalArgumentException(
47                    "Cannot add a " + TAG + " directly to a " + TAG);
48        }
49
50        return super.onPrepareAddPreference(preference);
51    }
52
53    @Override
54    public boolean isEnabled() {
55        return false;
56    }
57
58}
59