Home | History | Annotate | Download | only in widget
      1 /*
      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 
     17 package android.widget;
     18 
     19 import android.view.View;
     20 import 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.
     26  * <p>
     27  * An {@link ExpandableListAdapter} declares it has one view type for its group items
     28  * and one view type for its child items. Although adapted for most {@link ExpandableListView}s,
     29  * 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
     33  * {@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  */
     39 public 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
     52      * @see #getGroupTypeCount()
     53      */
     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
     69      * @see #getChildTypeCount()
     70      */
     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>
     82      * This method will only be called when the adapter is set on the {@link AdapterView}.
     83      *
     84      * @return The number of types of group Views that will be created by this adapter.
     85      * @see #getChildTypeCount()
     86      * @see #getGroupType(int)
     87      */
     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>
     99      * This method will only be called when the adapter is set on the {@link AdapterView}.
    100      *
    101      * @return The total number of types of child Views that will be created by this adapter.
    102      * @see #getGroupTypeCount()
    103      * @see #getChildType(int, int)
    104      */
    105     int getChildTypeCount();
    106 }
    107