blob: e7e09337209f7be1778136244d1cd8f3cbfacd49 [file] [log] [blame]
Gilles Debunne8340afe2010-03-11 16:25:13 -08001/*
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
17package android.widget;
18
19import android.view.View;
20import android.view.ViewGroup;
21
22/**
23 * Additional methods that when implemented make an
24 * {@link ExpandableListAdapter} take advantage of the {@link Adapter} view type
25 * mechanism.
Gilles Debunne8e364ed2010-07-28 09:00:41 -070026 * <p>
27 * An {@link ExpandableListAdapter} declares it has one view type for its group items
Gilles Debunne8340afe2010-03-11 16:25:13 -080028 * and one view type for its child items. Although adapted for most {@link ExpandableListView}s,
Gilles Debunne8e364ed2010-07-28 09:00:41 -070029 * these values should be tuned for heterogeneous {@link ExpandableListView}s.
30 * </p>
31 * Lists that contain different types of group and/or child item views, should use an adapter that
32 * implements this interface. This way, the recycled views that will be provided to
Gilles Debunne8340afe2010-03-11 16:25:13 -080033 * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
34 * and
35 * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
36 * will be of the appropriate group or child type, resulting in a more efficient reuse of the
37 * previously created views.
38 */
39public interface HeterogeneousExpandableList {
40 /**
41 * Get the type of group View that will be created by
42 * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
43 * . for the specified group item.
44 *
45 * @param groupPosition the position of the group for which the type should be returned.
46 * @return An integer representing the type of group View. Two group views should share the same
47 * type if one can be converted to the other in
48 * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
49 * . Note: Integers must be in the range 0 to {@link #getGroupTypeCount} - 1.
50 * {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
51 * @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
Gilles Debunne8e364ed2010-07-28 09:00:41 -070052 * @see #getGroupTypeCount()
Gilles Debunne8340afe2010-03-11 16:25:13 -080053 */
54 int getGroupType(int groupPosition);
55
56 /**
57 * Get the type of child View that will be created by
58 * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
59 * for the specified child item.
60 *
61 * @param groupPosition the position of the group that the child resides in
62 * @param childPosition the position of the child with respect to other children in the group
63 * @return An integer representing the type of child View. Two child views should share the same
64 * type if one can be converted to the other in
65 * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
66 * Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
67 * {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
68 * @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
Gilles Debunne8e364ed2010-07-28 09:00:41 -070069 * @see #getChildTypeCount()
Gilles Debunne8340afe2010-03-11 16:25:13 -080070 */
71 int getChildType(int groupPosition, int childPosition);
72
73 /**
74 * <p>
75 * Returns the number of types of group Views that will be created by
76 * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
77 * . Each type represents a set of views that can be converted in
78 * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
79 * . If the adapter always returns the same type of View for all group items, this method should
80 * return 1.
81 * </p>
Gilles Debunne8340afe2010-03-11 16:25:13 -080082 * This method will only be called when the adapter is set on the {@link AdapterView}.
Gilles Debunne8340afe2010-03-11 16:25:13 -080083 *
84 * @return The number of types of group Views that will be created by this adapter.
Gilles Debunne8e364ed2010-07-28 09:00:41 -070085 * @see #getChildTypeCount()
86 * @see #getGroupType(int)
Gilles Debunne8340afe2010-03-11 16:25:13 -080087 */
88 int getGroupTypeCount();
89
90 /**
91 * <p>
92 * Returns the number of types of child Views that will be created by
93 * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
94 * . Each type represents a set of views that can be converted in
95 * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
96 * , for any group. If the adapter always returns the same type of View for
97 * all child items, this method should return 1.
98 * </p>
Gilles Debunne8340afe2010-03-11 16:25:13 -080099 * This method will only be called when the adapter is set on the {@link AdapterView}.
Gilles Debunne8340afe2010-03-11 16:25:13 -0800100 *
101 * @return The total number of types of child Views that will be created by this adapter.
Gilles Debunne8e364ed2010-07-28 09:00:41 -0700102 * @see #getGroupTypeCount()
103 * @see #getChildType(int, int)
Gilles Debunne8340afe2010-03-11 16:25:13 -0800104 */
105 int getChildTypeCount();
106}